ㅁ How many StorageClasses exist in the cluster right now?
kubectl get storageclasses
ㅁ How about now? How many Storage Classes exist in the cluster? we just created a few new Storage Classes. Inspect them
$ kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-storage kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 10s
portworx-io-priority-high kubernetes.io/portworx-volume Delete Immediate false 10s
ㅁ What is the name of the Storage Class that does not support dynamic volume provisioning?
[portWorx-Storageclass]
[glusterfs-sc]
[nfs-sc]
[local-storage]
ㅁ What is the Volume Binding Mode used for this storage class (the one identified in the previous question)
[WaiForFirstConsumer]
[Immediate]
ㅁ What is the Provisioner used for the storage class called portworx-io-priority-high?
[no-provisioner]
[ceph-volu]
[local-volume]
[portworx-volume]
ㅁ Is there a PersistentVolumeClaim that is consuming the PersistentVolume called local-pv?
$ kubectl get pvc
No resources found in default namespace.
[YES] [NO]
ㅁ Let's fix that. Creat a new PersistentVolumeClaim by the name of local-pvc that should bind to the volume local-pv. Inspect the pv local-pv for the specs.
- PVC: local-pvc
- Corrrect Access Mode?
- Correct StorageClass Used?
- PVC requests volume size = 500Mi?
$ kubectl describe pv local-pv
Name: local-pv
Labels: <none>
Annotations: <none>
Finalizers: [kubernetes.io/pv-protection]
StorageClass: local-storage
Status: Available
Claim:
Reclaim Policy: Retain
Access Modes: RWO
VolumeMode: Filesystem
Capacity: 500Mi
Node Affinity:
Required Terms:
Term 0: kubernetes.io/hostname in [controlplane]
Message:
Source:
Type: LocalVolume (a persistent volume backed by local storage on a node)
Path: /opt/vol1
local-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: local-pvc
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 500Mi
storageClassName: local-storage
ㅁ What is the status of the newly created Persistent Volume Claim?
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
local-pvc Pending local-storage 8m43s
ㅁ Why is the PVC in a pending state despite making a valid request to claim the volume called local-pv?
[Storage class not found]
[PVC Specs are Incorrect]
[Persistent Volume and Claim mismatch]
[A Pod consuming the volume is not scheduled]
$ kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-storage kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 24m
portworx-io-priority-high kubernetes.io/portworx-volume Delete Immediate false 24m
$ kubectl get pods
No resources found in default namespace.
Note: The Storage Class called local-storage makes use of VolumeBindingMode set to WaitForFirstConsumer. This will delay the binding and provisioning of a PersistentVolume until a Pod using the PersistentVolumeClaim is created
ㅁ Create a new pod called nginx with the image nginx:alpine. The Pod should make use of the PVC local-pvc and mount the volume at the path /var/www/html.
The PV local-pv should in a bound state
- Pod created with the correct Image?
- Pod uses PVC called local-pvc?
- local-pv bound?
- nginx pod running?
- Volume mounted at the correct path?
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx:alpine
volumeMounts:
- name: html-vol
mountPath: /var/www/html
volumes:
- name: html-vol
persistentVolumeClaim:
claimName: local-pvc
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
local-pvc Bound local-pv 500Mi RWO local-storage 21m
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 29s
$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
local-pv 500Mi RWO Retain Bound default/local-pvc local-storage 34m
ㅁ What is the status of the local-pvc Persistent Volume Claim now?
[Bound]
ㅁ Create a new Storage Class called delayed-volume-sc that makes use of the below specs:
- provisioner: kubernetes.io/no-provisioner
- volumeBindingMode: WaitForFirstConsumer
sc-definition.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: delayed-volume-sc
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
$ kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
delayed-volume-sc kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 47s
local-storage kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 50m
portworx-io-priority-high kubernetes.io/portworx-volume Delete Immediate false 50m