State Persistence Flashcards

1
Q

What is a persistent volume?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does a Persistent Volume differ from a Volume?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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)

A

spec: volumes: - name: data-volume hostPath: path: /data type: Directory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In a Pod definition, how is a volume applied to a container?

A

spec: containers: - volumeMounts: - mountPath: /opt name: data-volume

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a hostPath volume type?

A

A hostPath volume mounts a file or directory from the host node’s filesystem into your Pod.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are some issues with the hostPath volume type?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an emptyDir volume type?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In a Pod definition, configure an emptyDir volume.

e.g. to /cache path of a container named test-container

A

spec: containers: - name: test-container volumeMounts: - mountPath: /cache name: empty-volume volumes: - name: empty-volume emptyDir: {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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)

A

spec: volumes: - name: data-volume awsElasticBlockStore: volumeID: myAWSEBSID fsType: ext4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the apiVersion of a Persistent Volume?

A

v1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the three types of Access Mode for a Persistent Volume?

A
  • ReadOnlyMany
  • ReadWriteOnce
  • ReadWriteMany
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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)

A

spec: accessModes: - ReadWriteOnce capacity: storage: 1Gi hostPath: path: /tmp/foo

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can a Persistent Volume be associated with a Pod

A

With a Persistent Volume Claim

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the imperative command to list all Persistent Volumes?

A

kubectl get pv

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What considerations does Kubernetes take into account when binding a Persistent Volume Claim to a Persistent Volume?

A
  • sufficient storage capacity
  • access modes
  • volume modes
  • storage class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

If no volumes are available, what is the state of any further Persistent Volume Claims?

A

Pending state

17
Q

What is the apiVersion of Persistent Volume Claim

A

v1

18
Q

In Persistent Volume Claim definition, how can a read-only volume be bound? (e.g. 500Mi storage)

A

spec: accessModes: - ReadWriteOnce resources: requests: storage: 500Mi

19
Q

What is the imperative command to list all Persistent Volume Claims?

A

kubectl get pvc

20
Q

In Pod definition, how is a Persistent Volume Claim associated with a container? (e.g. a PVC named my-pvc, mounted at /var/www)

A

spec: containers: - volumemounts: - mountPath: "/var/www" name: myVolume volumes: - name: myVolume persistentVolumeClaim: claimName: my-pvc