State Persistence Flashcards
What is a persistent volume?
A PersistentVolume (PV) is a piece of storage in the cluster. It is a resource in the cluster just like a node is a cluster resource. PVs have a lifecycle independent of any individual Pod that uses the PV.
How does a Persistent Volume differ from a Volume?
A persistent volume is a subset of Volumes, where data can be persisted beyond the lifecycle of a Pod that uses it. Volumes are often ephemeral and are created as a Pod is started and deleted with the Pod.
In a Pod definition, how is a volume created from a Directory on the host node? (e.g. a directory on the host node at a path of /data)
spec: volumes: - name: data-volume hostPath: path: /data type: Directory
In a Pod definition, how is a volume applied to a container?
spec: containers: - volumeMounts: - mountPath: /opt name: data-volume
What is a hostPath volume type?
A hostPath volume mounts a file or directory from the host node’s filesystem into your Pod.
What are some issues with the hostPath volume type?
The volume on each node is different, and is not synchronised between nodes. The files or directories created on the underlying hosts are only writable by root. You either need to run your process as root in a privileged Container or modify the file permissions on the host to be able to write to a hostPath volume
What is an emptyDir volume type?
An emptyDir volume is first created when a Pod is assigned to a node, and exists as long as that Pod is running on that node. As the name says, the emptyDir volume is initially empty. All containers in the Pod can read and write the same files in the emptyDir volume, though that volume can be mounted at the same or different paths in each container. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted permanently.
In a Pod definition, configure an emptyDir volume.
e.g. to /cache path of a container named test-container
spec: containers: - name: test-container volumeMounts: - mountPath: /cache name: empty-volume volumes: - name: empty-volume emptyDir: {}
In a Pod definition, how is a volume created from AWS Elastic Block Store (EBS)? (e.g. AWS EBS with ID of myAWSEBSID, and a file system type of ext4)
spec: volumes: - name: data-volume awsElasticBlockStore: volumeID: myAWSEBSID fsType: ext4
What is the apiVersion of a Persistent Volume?
v1
What are the three types of Access Mode for a Persistent Volume?
- ReadOnlyMany
- ReadWriteOnce
- ReadWriteMany
In a PersistentVolume definition, how can a read-only volume be created from a directory in the host? (e.g. 1Gi at a path of /tmp/foo)
spec: accessModes: - ReadWriteOnce capacity: storage: 1Gi hostPath: path: /tmp/foo
How can a Persistent Volume be associated with a Pod
With a Persistent Volume Claim
What is the imperative command to list all Persistent Volumes?
kubectl get pv
What considerations does Kubernetes take into account when binding a Persistent Volume Claim to a Persistent Volume?
- sufficient storage capacity
- access modes
- volume modes
- storage class