Storage Flashcards
What types of volume types are there? Describe them
emptyDir - empty dir in Pod with read write access, persisted only for the duration of the pod
hostPath - file or dir from hosts node filesystem
configMapSecret - Provides a way to inject configuration data
nfs - network file system share. Preserves data after pod restart
persistentVolumeClaim - claims a persistent volume resource
What is the difference between emptyDir and hostPath?
emptyDir is persisted only for the duration of the pod and must be an empty directory, hostPath can be a directory or file and can already exist in the host or can be created on Pod startup
What is the use case for emptyDir and hostPath?
emptyDir might be used for scratch space, cache or for an algorithm
hostPath might be used when a container needs access to docker internals or if a process running inside it needs access to the host
How would you create a volume in a pod yaml file?
apiVersion: v1
kind: Pod
metadata:
name: a-pod
spec:
volumes:
- name: a-volume
emptyDir: {}
container:
- name: a-container
image: nginx
volumeMounts:
- name: a-volume
mountPath: /var/logs
What’s the yaml file for a persistent volume?
apiVersion: v1
kind: PersistentVolume
metadata:
name: a-volume
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
hostPath:
path: /var/logs
What are the configuration optons for a pv?
Storage capacity : 1GI e.g.
hostPath
StorageClassName
Access modes:
- ReadWriteOnce RWO
- ReadWriteMany RWX
- ReadOnlyOnce ROX
- ReadWriteOncePod RWOP
Volume mode:
- filesystem
- block
Reclaim policy:
- Retain (Default)
- Delete
What is the yaml file for a pvc that is statically provisioned, requires readwriteonce access and 256Mi of storage?
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: a-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: “”
resources:
requests:
storage: 256Mi
After creating a pvc what does the “Bound” status mean?
It means that the pvc found a pv to attatch to
Using an yaml file, how would you attatch a pvc to a pod?
apiVersion: v1
kind: Pod
metadata:
name: a-pod
spec:
volumes:
- name: a-volume
persistentVolumeClaim:
claimName: a-pvc
containers:
- name: a-container
image: alpine
volumeMounts:
- name: a-volume
mountPath: /var/log
What is a storage class?
A storage class is a kunernetes primitive that defines a specific type or claim of storage