PVC(PersistentVolumeClaim) 를 생성하고 Pod 에 마운트하기

Print

IBM Cloud의 Storage 종류

  • Block Storage

    • Access Modes 에 "ReadWriteOne" 가능

    • Storage 공유 불가

  • File Storage

    • Access Modes 에 "ReadWriteMany" 가능

    • Pods이 여러개 뜰 경우 storage 공유 가능

등급

  • bronze~gold : 고정적인 IOPS로 Storage Size 선택
  • custom : Storage Size 및 Size에 맞는 IOPS선택

bronzesilvergoldcustom
iopsPerGB2410
sizeRange[20-12000]Gi[20-12000]Gi[20-4000]Gi
sizeIOPSRange


[20-39]Gi : [100-1000]
[40-79]Gi : [100-2000]
[80-99]Gi : [100-4000]
[100-499]Gi : [100-6000]
[500-999]Gi : [100-10000]
[1000-1999]Gi : [100-20000]
[2000-2999]Gi : [200-40000]
[3000-3999]Gi : [200-48000]
[4000-7999]Gi : [300-48000]
[8000-9999]Gi : [500-48000]
[10000-12000]Gi : [1000-48000]


빌링

  • monthly 또는 hourly (임시 테스트 생성 시 hourly 사용 권장)

persistentVolume Reclaim Policy 값

  • ibmc-block-{등급} : "delete"

  • ibmc-block-retain-{등급} : "retain"


생성 예시

ibmc-block-retain-silver

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-myapp
  annotations:
    volume.beta.kubernetes.io/storage-class: "ibmc-block-retain-silver"
  labels:
    billingType: "monthly"
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi


ibmc-block-retain-custom

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-myapp
  annotations:
    volume.beta.kubernetes.io/storage-class: "ibmc-block-retain-custom"
  labels:
    billingType: "monthly"
spec:
  accessModes:
    - ReadWriteOnce   # file storage인 경우에는 - ReadWriteMany
  resources:
    requests:
      storage: 20Gi
      iops: "1000"

생성된 PVC 를 Deployment 에 마운트

apiVersion: apps/v1
kind: Deployment
metadata:
  name: <deployment_name>
  labels:
    app: <deployment_label>
spec:
  selector:
    matchLabels:
      app: <app_name>
  template:
    metadata:
      labels:
        app: <app_name>
    spec:
      containers:
      - image: <image_name>
        name: <container_name>
        volumeMounts:
        - name: <volume_name>
          mountPath: /<file_path>
      volumes:
      - name: <volume_name>
        persistentVolumeClaim:
          claimName: <pvc_name>

생성된 PVC 를 StatefulSet 에 마운트

apiVersion: apps/v1
kind: StatefulSet
metadata:
 name: web
spec:
 serviceName: "nginx"
 replicas: 3
 podManagementPolicy: "Parallel"
 selector:
   matchLabels:
     app: nginx
 template:
   metadata:
     labels:
       app: nginx
   spec:
     affinity:
       podAntiAffinity:
         preferredDuringSchedulingIgnoredDuringExecution:
         - weight: 100
       podAffinityTerm:
         labelSelector:
           matchExpressions:
               - key: app
             operator: In
             values:
                 - nginx
             topologyKey: failure-domain.beta.kubernetes.io/zone
     containers:
     - name: nginx
       image: k8s.gcr.io/nginx-slim:0.8
       ports:
       - containerPort: 80
         name: web
       volumeMounts:
       - name: www
         mountPath: /usr/share/nginx/html
       - name: wwwww
         mountPath: /tmp1
 volumeClaimTemplates:
 - metadata:
     name: myvol1
   spec:
     accessModes:
     - ReadWriteMany # access mode
     resources:
       requests:
         storage: 20Gi
     storageClassName: ibmc-file-bronze-delayed
 - metadata:
     name: myvol2
   spec:
     accessModes:
     - ReadWriteMany # access mode
     resources:
       requests:
         storage: 20Gi
     storageClassName: ibmc-file-bronze-delayed

References

이 답변이 유용합니까? 아니오

Send feedback
도움이 되어드리지 못해 죄송합니다. 아티클 개선을 위해 의견을 제공해 주시기 바랍니다.