State Persistence - Volumes Flashcards

1
Q

How can we specify a volume with Directory for data to be saved by a pod?

A
... 
kind: Pod
...
spec:
 containers:
 - image: ...
   volumeMounts:
	 - mountPath: /opt
	   name: data-volume
 volumes:
 - name: data-volume
   hostPath: 
	   path: /data
	  	type: Directoy

-> data volume is mounted on the path /opt on the container
-> therefore /opt is on the /data volume/Directory on the host

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

What options do exist for volume types?

A
  • data-volume: only useful with one node
  • different third party solutions, like aws elastic block storage
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the downside of regular volumes in large environment?

A
  • every pod definition file defines its volume
  • changes would need to be made to all pods
  • a more centralized approach can be preffered
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a persistent Volume?

A
  • cluster-wide pool of storage volumes
  • configured by an administrator
  • to be used by users deploying applications on the cluster (via PVC)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you define a persistent Volume?

A
apiVersion: v1
kind: PersistentVolume
metadata: 
  name: pv-voll
spec:
  accessModes:
	  - ReadWriteOnce (// ReadOnlyMany//ReadWriteMany)
	  capacity:
		  storage: 1Gi
		hostPath: (not to be used in production, replaced by third party solution)
		  path: /tmp/data
	persistentVolumeReclaimPolicy: Retain / Delete / Recycle
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are Persistent Volumes and Persistent Volume claims?

A
  • separate objects in Kubernetes namespace
  • admin creates set of persistent volumes
  • user creates persistent volume claims to use the storage
  • once pvcs are created, Kubernetes binds them to PVs based on the request and properties set on the volume
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

To how many PVs is a PVC bound?

A
  • to only one
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What request characteristics define whether a PVC and a PV are bound together?

A
  • sufficient capacity
  • Access Modes
  • Volume Modes
  • Storage Class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can you select a specific type of PV, if all other characters match?

A

Using Selector and Labels

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

What happens if only larger then the PVC PVs are available

A
  • both are bound together
  • the remaining capacity of the PV is not used
  • 1 to 1 relationship between PV and PVC
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What happens if no fitting PV is available to a PVC

A

PVC remains in a pending state

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

How do you define a persistent volume claim?

A
apiVersion:
kind: PersistentVolumeClaim
metadata:
  name: myclaim
spec:
  accessModes:
	  - ReadWriteOnce
	 resources:
	   requests:
		   storage: 500Mi
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What happens to a PersistentVolume once a Claim gets deleted?

A
  • configurable by Reclaim policy
  • by default: Retain -> will remain till manually deleted by the admin, not available for reuse by any other claims
  • Delete: deletes the PVs automatically
  • Recycle: data in Data volume will be scrubbed before making it available to other claims
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can we use PVCs in pods?

A

pod.yaml
~~~
spec:
containers:
- name: myfrontend
image: nginx
volumeMounts:
- mountPath: “/var/www/html”
name: mypd
volumes:
- name: mypd
persistentVolumeClaim:
claimName: myclaim
~~~

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

What volume Type is used to store data in a Pod only as long as that Pod is running on that node?

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

What happens when you delete a PVC that is used by a pod?

A
  • it is stuck in Status Terminating
17
Q
A