IT/Kubernetes

[CKA] StorageClass 란?

어린이개발자 2025. 11. 21. 18:12

이번엔 StorageClass 에 대해 정리하고자 한다.

 

1. 정의

- 쿠버네티스에서 PersistentVolume(PV) 을 자동으로 생성하기 위한 스토리지 정책 템플릿

즉, Pod 가 PVC(Persistent Volume Claim) 을 요청하면 StorageClass 가 알맞은 스토리지를 자동으로 생성(provisioning) 해주는 구조

 

2. 특징

- 동적 프로비저닝

  > PVC 가 생성될 때 PV 를 자도으로 만들어줌

- 다양한 스토리지 공급자 지원

- 스토리지 타입/성능/설정 정의

 

3. 관련 문제 (KodeKloud 에서 제공하는 샘플 문제를 정리)

- How many Storage Classes exist in the cluster?

kubectl get storageclasses

 

- Create a new PersistentVolumeClaim named local-pvc with the following configuration:

  > StorageClass: local-path

  > Access Mode: ReadWriteOnce

  > Requested Storage: 500Mi

  > Do not use the volumeName field in the PVC.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: local-pvc
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: local-path
  resources:
    requests:
      storage: 500Mi
kubectl apply -f local-pvc.yaml

 

- What is the status of the newly created Persistent Volume Claim?

kubectl get pvc local-pvc

 

- Why is the PVC still in a pending state, even though it includes a valid request using the local-path storage class?

kubectl describe pvc local-pvc | grep -A3 Events

 

 

- 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.

kubectl run nginx --image=nginx:alpine --dry-run=client -o yaml > nginx.yaml
vi nginx.yaml
// spec/containers 아래에 
volumeMounts: 
  - name: local-persistent-storage
  mountPath: /var/www/html

// spec 아래에
volumes:
 - name: local-persistent-storage
 persistentVolumeClaim:
   claimName: local-pvc
kubectl apply -f nginx.yaml

 

- Create a new Storage Class called delayed-volume-sc that makes use of the below specs:

  > provisioner: kubernetes.io/no-provisioner
  > volumeBindingMode: WaitForFirstConsumer

vi delayed-volume-sc.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: delayed-volume-sc
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
kubectl apply -f delayed-volume-sc.yaml

 

4. 출처

- https://learn.kodekloud.com/user/courses/udemy-labs-certified-kubernetes-administrator-with-practice-tests

'IT > Kubernetes' 카테고리의 다른 글

[CKA] NetworkPolicy 란?  (0) 2025.11.22
[CKA] PV(PersistentVolume) 란?  (0) 2025.11.22
[CKA] PriorityClass 란?  (0) 2025.11.21
[CKA] Deployment 란?  (0) 2025.11.21
[CKA] ReplicaSet 이란?  (0) 2025.11.21