Exercise 8.3: Creating a Persistent Volume Claim (PVC)

  1. CP 노드에 연결된 터미널로 이동

  2. 생성된 PVC가 있는지 확인

    kubectl get pvc
  3. PVC 생성

    cat <<EOF | kubectl create -f -
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: pvc-one
    spec:
      accessModes:
      - ReadWriteMany
      resources:
         requests:
           storage: 200Mi
    EOF
  4. 생성된 PVC 확인

    kubectl get pvc pvc-one
  5. 이전 실습에서 생성된 PV 확인

    kubectl get pv nfs
  6. Deployment 생성

    cat <<EOF | kubectl create -f -
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        run: nginx
      name: nginx-nfs
    spec:
      selector:
        matchLabels:
          run: nginx
      template:
        metadata:
          labels:
            run: nginx
        spec:
          containers:
          - image: nginx
            imagePullPolicy: Always
            name: nginx
            volumeMounts:
            - name: nfs-vol
              mountPath: /opt
            ports:
            - containerPort: 80
              protocol: TCP
          volumes:
          - name: nfs-vol
            persistentVolumeClaim:
              claimName: pvc-one
    EOF
  7. 생성된 Pod 확인

    kubectl get pod -l run=nginx
  8. 생성된 Pod 상세 내용 확인

    kubectl describe pod POD_NAME

    OR

    kubectl describe pod $(kubectl get pod -l run=nginx -o=jsonpath='{.items[0].metadata.name}') 
  9. Pod가 생성되지 않을 경우에는 이유를 찾아서 고치세요

  10. PVC 상태 확인

    kubectl get pvc pvc-one

Last updated