Storage
01. Persistent Volume Claims
02. Storage
01. How many StorageClasses exist in the cluster right now?
ask : 1
controlplane ~ ➜ k get StorageClass
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-path (default) rancher.io/local-path Delete WaitForFirstConsumer false 5m15s
02. How about now? How many Storage Classes exist in the cluster?
We just created a few new Storage Classes. Inspect them.
controlplane ~ ➜ k get StorageClass
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-path (default) rancher.io/local-path Delete WaitForFirstConsumer false 6m10s
local-storage kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 33s
portworx-io-priority-high kubernetes.io/portworx-volume Delete Immediate false 33s
03. What is the name of the Storage Class that does not support dynamic volume provisioning?
1) portWorx-Storageclass
2) glusterfs-sc
3) nfs-sc
4) local-storage
Hint : Look for the storage class name that uses no-provisioner
04. What is the Volume Binding Mode used for this storage class (the one identified in the previous question).
1) Immediate
2) WaitForFirstConsumer
Run the command: kubectl describe sc local-storage or kubectl get sc
and look under the Volume Binding Mode section.
controlplane ~ ➜ k describe sc local-storage
Name: local-storage
IsDefaultClass: No
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{},"name":"local-storage"},"provisioner":"kubernetes.io/no-provisioner","volumeBindingMode":"WaitForFirstConsumer"}
Provisioner: kubernetes.io/no-provisioner
Parameters: <none>
AllowVolumeExpansion: <unset>
MountOptions: <none>
ReclaimPolicy: Delete
VolumeBindingMode: WaitForFirstConsumer
Events: <none>
05. What is the Provisioner used for the storage class called portworx-io-priority-high?
1) no-provisioner
2) local-volume
3) portworx-volume
4) ceph-volue
Run the command: kubectl describe sc portworx-io-priority-high
or
kubectl get sc portworx-io-priority-high
and look under the PROVISIONER section.
controlplane ~ ➜ kubectl describe sc portworx-io-priority-high
Name: portworx-io-priority-high
IsDefaultClass: No
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{},"name":"portworx-io-priority-high"},"parameters":{"priority_io":"high","repl":"1","snap_interval":"70"},"provisioner":"kubernetes.io/portworx-volume"}
Provisioner: kubernetes.io/portworx-volume
Parameters: priority_io=high,repl=1,snap_interval=70
AllowVolumeExpansion: <unset>
MountOptions: <none>
ReclaimPolicy: Delete
VolumeBindingMode: Immediate
Events: <none>
06. Is there a PersistentVolumeClaim that is consuming the PersistentVolume called local-pv?
ask : NO
controlplane ~ ➜ k get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
local-pv 500Mi RWO Retain Available local-storage 6m57s
controlplane ~ ➜ k get pvc
No resources found in default namespace.
07. Let's fix that. Create 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
- Correct Access Mode?
- Correct StorageClass Used?
- PVC requests volume size = 500Mi?
Inspect the persistent volume and look for the Access Mode,
Storage and StorageClassName used. Use this information to create the PVC.
# local-pv yaml
--
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-pv
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 500Mi
local:
path: /opt/vol1
persistentVolumeReclaimPolicy: Retain
storageClassName: local-storage
volumeMode: Filesystem
Use the below YAML file to create the PersistentVolumeClaim local-pvc:
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: local-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage
resources:
requests:
storage: 500Mi
08. What is the status of the newly created Persistent Volume Claim?
ask : Pending
controlplane ~ ➜ k get pvc,pv
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistentvolumeclaim/local-pvc Pending local-storage 49s
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
persistentvolume/local-pv 500Mi RWO Retain Available local-storage 14m
09. Why is the PVC in a pending state despite making a valid request to claim the volume called local-pv?
local-pv라는 볼륨을 요청하기 위해 유효한 요청을 했음에도 불구하고 PVC가 보류 상태인 이유는 무엇입니까?
Inspect the PVC events.
1) Persistent Volume and Claim mismatch
2) PVC Specs are Incorrect
3) Storage Class not found
4) A Pod consuming the volume is not scheduled
볼륨을 사용하는 Pod가 예약되지 않았습니다.
10. The Storage Class called local-storage makes use of VolumeBindingMode set to WaitForFirstConsumer.
local-storage라는 스토리지 클래스는 WaitForFirstConsumer로 설정된 VolumeBindingMode를 사용합니다.
This will delay the binding and provisioning of a PersistentVolume until a Pod using the PersistentVolumeClaim is created.
local-storage라고 하는 스토리지 클래스는 VolumeBindingModeThis를 사용하여 PersistentVolumeClaim을 사용하는 파드가 생성될 때까지 PersistentVolume의 바인딩 및 프로비저닝을 지연시킵니다. WaitForFirstConsumer로 설정합니다.
11. 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?
Use the command
kubectl run to create a pod definition file for nginx pod with image nginx:alpine.
Add mount volume path /var/www/html and pvc given in the details.
Alternatively, run the command:
kubectl run nginx --image=nginx:alpine --dry-run=client -oyaml > nginx.yaml
Solution manifest file to create a pod called nginx is as follows:
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
name: nginx
spec:
containers:
- name: nginx
image: nginx:alpine
volumeMounts:
- name: local-persistent-storage
mountPath: /var/www/html
volumes:
- name: local-persistent-storage
persistentVolumeClaim:
claimName: local-pvc
12. What is the status of the local-pvc Persistent Volume Claim now?
1) AVAILABLE
2) ERROR
3) BOUND
4) PENDING
5) TERMINATING
controlplane ~ ✖ k get pv,pvc
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
persistentvolume/local-pv 500Mi RWO Retain Bound default/local-pvc local-storage 27m
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistentvolumeclaim/local-pvc Bound local-pv 500Mi RWO local-storage 13m
13. Create a new Storage Class called delayed-volume-sc that makes use of the below specs:
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
- Storage Class uses: kubernetes.io/no-provisioner ?
- Storage Class volumeBindingMode set to WaitForFirstConsumer ?
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: delayed-volume-sc
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
Bookmark
https://kubernetes.io/ko/docs/concepts/storage/storage-classes/
https://kubernetes.io/docs/concepts/storage/persistent-volumes/
https://kubernetes.io/ko/docs/tasks/configure-pod-container/configure-persistent-volume-storage/
'CKA (Certified Kubernetes Administrator) > Kode Kloud' 카테고리의 다른 글
06.Security - Role Based Access Controls (0) | 2022.01.25 |
---|---|
06.Security - KubeConfig (0) | 2022.01.25 |
07.Storage - Persistent Volume Claims (0) | 2022.01.25 |
06.Security - View Certificate Details (0) | 2022.01.24 |
05.Cluster Maintenance - Backup and Restore Methods (0) | 2022.01.24 |