Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Persistent Volume Claim(PVC) Manifest

Code Block
titlestatefulsetpvc.yaml
linenumberstrue
collapsetrue
aapiVersionapiVersion: apps/v1
kind: StatefulSetPersistentVolumeClaim
metadata:
  name: webfoo-pvc
spec:
  selectorstorageClassName:
    matchLabels:
      app: nginx
  serviceName: "nginx"
  replicas: 3 # 기본값은 1
  minReadySeconds: 10 # 기본값은 0
  template:
    metadata:
      labels:
        app: nginx
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: nginx
        image: nginx:1.15.12
        ports:
        - containerPort: 80
          name: web
        volumeMounts:
        - name: www
          mountPath: /usr/share/nginx/html
  volumeClaimTemplates:
  - metadata:
      name: www
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: azurefile
      resources:
         azurefile # 빈 문자열은 명시적으로 설정해야 하며 그렇지 않으면 기본 스토리지클래스가 설정됨
  volumeName: foo-pv
  resources:
    requests:
          storage: 1Gi

Persistent Volume Claim 실습

Info
iconfalse
Code Block
sansae@sansaeAir15m2 k8s-lab-workspace % k get pv
No resources found
sansae@sansaeAir15m2 k8s-lab-workspace % k get pvc
No resources found in default namespace.

Code Block
titlestatefulset.yaml
linenumberstrue
collapsetrue
sansae@sansaeAir15m2 k8s-lab-workspace % k apply -f statefulset.yaml 
service/nginx-stps created
statefulset.apps/web created

sansae@sansaeAir15m2 k8s-lab-workspace % k get pvc
NAME        STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
www-web-0   Bound    pvc-d7a6b825-edeb-4f06-813f-eef6abe19398   1Gi        RWO            azurefile      52s
www-web-1   Bound    pvc-a2ebaeef-ae82-47bc-8988-6bb6ca0a9067   1Gi        RWO            azurefile      32s
www-web-2   Bound    pvc-e17e5080-4403-4131-9d2b-f143431681df   1Gi        RWO            azurefile      12s

sansae@sansaeAir15m2 k8s-lab-workspace % k get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM               STORAGECLASS   REASON   AGE
pvc-a2ebaeef-ae82-47bc-8988-6bb6ca0a9067   1Gi        RWO            Delete           Bound    default/www-web-1   azurefile               55s
pvc-d7a6b825-edeb-4f06-813f-eef6abe19398   1Gi        RWO            Delete           Bound    default/www-web-0   azurefile               74s
pvc-e17e5080-4403-4131-9d2b-f143431681df   1Gi        RWO            Delete           Bound    default/www-web-2   azurefile               34s


...