Volumes,Persistent Volumes and PVC Flashcards

1
Q

What are volumes ?

A

when a container restarts the state of application is reset. To keep some state we require volume concept .
Also when sharing files between two containers in a POD , we use volumes

ex:- awsElasticBlockStore ; azureDisk ;
configMap (after u create a confiMap object , you can use configMap type in POD to consume the configuration inside a container )

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

what is persistent volume ?

A

PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes

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

persistent volume claim - volume type

A

A persistentVolumeClaim volume is used to mount a PersistentVolume into a Pod. PersistentVolumeClaims are a way for users to “claim” durable storage (such as a GCE PersistentDisk or an iSCSI volume) without knowing the details of the particular cloud environment.

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

what is persistent volume claim ?

A

PersistentVolumeClaim (PVC) is a request for storage by a user

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

secret volume

A

A secret volume is used to pass sensitive information, such as passwords, to Pods. You can store secrets in the Kubernetes API and mount them as files for use by Pods without coupling to Kubernetes directly. secret volumes are backed by tmpfs (a RAM-backed filesystem) so they are never written to non-volatile storage

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

imperative commands for pv, pvc

A

$ alias k=kubectl
$ k create -f pv.yaml [if declarative
$ k get pv , pvc

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

declarative

persistent volumes

A
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv0003
spec:
  capacity:
    storage: 5Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  mountOptions:
    - hard
    - nfsvers=4.1
  nfs:
    path: /tmp
    server: 172.17.0.2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

persitent volume claims ? write declarative

A
  • every persistentvolumeclaim binds to one persistentvolume
  • you can also customize to bind to a particular PersistentVolume by using labels and selectors
    also
  • claimRef tag is used on PV to bind to PVC , volumeName can be used to bing PVC to PV
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: myclaim
spec:
 accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi

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

how to check if persistent volume is there on pod or not

A

$ kubectl describe po pod-name

and check for Volumes: in it

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

check the logs in a container
POD: webapp
log path : /log/app.log

A

$ kubectl exec -it webapp – cat /log/app.log

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

volumeMount Vs volumes field

A

volumeMounts:
- mountPath: /var/log

it is the path inside a container where you want to mount a volume

volumes:

  • name: vol-log
    hostpath:
    path: /log/app

volumes ( 23+ types )
different types of volumes are present .
for example hostpath is the path from underlying host (node) which can be mounted to a container

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

create PV for hostpath

path: /app/log
storage: 5Gi

A
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv0003
spec:
  capacity:
    storage: 5Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteMany
  hostpath:
    path: /var/log
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

when access modes differ for Persistent volume and Persistent volume claim , does pvc bind to pv

A

NO

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

when does a PVC get stuck in TERMINATING state

A

when the PVC is being used by a POD

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