14.3. 클러스터에서 NFS 내보내기 사용

Kubernetes 애플리케이션 Pod는 이전에 생성된 PVC를 마운트하여 생성된 NFS 내보내기를 사용할 수 있습니다.

PVC는 다음 두 가지 방법 중 하나를 마운트할 수 있습니다.

YAML 사용:

다음은 14.2절. “NFS 내보내기 생성” 에서 생성된 예제 PVC를 사용하는 예제 Pod의 예입니다.

apiVersion: v1
kind: Pod
metadata:
 name: nfs-export-example
spec:
 containers:
   - name: web-server
     image: nginx
     volumeMounts:
       - name: nfs-export-pvc
         mountPath: /var/lib/www/html
 volumes:
   - name: nfs-export-pvc
     persistentVolumeClaim:
       claimName: <pvc_name>
       readOnly: false
<pvc_name>
이전에 생성한 PVC(예: my-nfs-export )를 지정합니다.

OpenShift Container Platform 웹 콘솔 사용.

프로세스

  1. OpenShift Container Platform 웹 콘솔에서 워크로드Pod 로 이동합니다.
  2. Create Pod 를 클릭하여 새 애플리케이션 Pod를 생성합니다.
  3. metadata 섹션 아래에 이름을 추가합니다. 예를 들어, 네임스페이스openshift-storagenfs-export-example 입니다.
  4. spec: 섹션에서 imagevolumeMounts 섹션이 포함된 containers: 섹션을 추가합니다.

    apiVersion: v1
    kind: Pod
    metadata:
     name: nfs-export-example
     namespace: openshift-storage
    spec:
     containers:
       - name: web-server
         image: nginx
         volumeMounts:
           - name: <volume_name>
             mountPath: /var/lib/www/html

    예를 들면 다음과 같습니다.

    apiVersion: v1
    kind: Pod
    metadata:
     name: nfs-export-example
     namespace: openshift-storage
    spec:
     containers:
       - name: web-server
         image: nginx
         volumeMounts:
           - name: nfs-export-pvc
             mountPath: /var/lib/www/html
  5. spec: 섹션에서 volumes: 섹션을 추가하여 NFS PVC를 애플리케이션 Pod의 볼륨으로 추가합니다.

    volumes:
      - name: <volume_name>
        persistentVolumeClaim:
          claimName: <pvc_name>

    예를 들면 다음과 같습니다.

    volumes:
      - name: nfs-export-pvc
        persistentVolumeClaim:
          claimName: my-nfs-export