28.2.6. 동일한 PVC를 참조할 추가 Pod 생성
동일한 네임스페이스에서 생성된 이 포드 정의는 다른 컨테이너를 사용합니다. 그러나 아래 볼륨 섹션에서 클레임 이름을 지정하여 동일한 백업 스토리지를 사용할 수 있습니다.
예 28.4. Pod 오브젝트 정의
apiVersion: v1 kind: Pod metadata: name: busybox-nfs-pod 1 labels: name: busybox-nfs-pod spec: containers: - name: busybox-nfs-pod image: busybox 2 command: ["sleep", "60000"] volumeMounts: - name: nfsvol-2 3 mountPath: /usr/share/busybox 4 readOnly: false securityContext: supplementalGroups: [100003] 5 privileged: false volumes: - name: nfsvol-2 persistentVolumeClaim: claimName: nfs-pvc 6
포드 정의를 파일에 저장하고(예: nfs-2.yaml ) Pod를 생성합니다.
# oc create -f nfs-2.yaml pod "busybox-nfs-pod" created
Pod가 생성되었는지 확인합니다.
# oc get pods NAME READY STATUS RESTARTS AGE busybox-nfs-pod 1/1 Running 0 3s
자세한 내용은 oc describe pod
명령에 표시됩니다.
[root@ose70 nfs]# oc describe pod busybox-nfs-pod Name: busybox-nfs-pod Namespace: default Image(s): busybox Node: ose70.rh7/192.168.234.148 Start Time: Mon, 21 Mar 2016 10:19:46 -0400 Labels: name=busybox-nfs-pod Status: Running Reason: Message: IP: 10.1.0.5 Replication Controllers: <none> Containers: busybox-nfs-pod: Container ID: docker://346d432e5a4824ebf5a47fceb4247e0568ecc64eadcc160e9bab481aecfb0594 Image: busybox Image ID: docker://17583c7dd0dae6244203b8029733bdb7d17fccbb2b5d93e2b24cf48b8bfd06e2 QoS Tier: cpu: BestEffort memory: BestEffort State: Running Started: Mon, 21 Mar 2016 10:19:48 -0400 Ready: True Restart Count: 0 Environment Variables: Conditions: Type Status Ready True Volumes: nfsvol-2: Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace) ClaimName: nfs-pvc ReadOnly: false default-token-32d2z: Type: Secret (a secret that should populate this volume) SecretName: default-token-32d2z Events: FirstSeen LastSeen Count From SubobjectPath Reason Message ───────── ──────── ───── ──── ───────────── ────── ─────── 4m 4m 1 {scheduler } Scheduled Successfully assigned busybox-nfs-pod to ose70.rh7 4m 4m 1 {kubelet ose70.rh7} implicitly required container POD Pulled Container image "openshift3/ose-pod:v3.1.0.4" already present on machine 4m 4m 1 {kubelet ose70.rh7} implicitly required container POD Created Created with docker id 249b7d7519b1 4m 4m 1 {kubelet ose70.rh7} implicitly required container POD Started Started with docker id 249b7d7519b1 4m 4m 1 {kubelet ose70.rh7} spec.containers{busybox-nfs-pod} Pulled Container image "busybox" already present on machine 4m 4m 1 {kubelet ose70.rh7} spec.containers{busybox-nfs-pod} Created Created with docker id 346d432e5a48 4m 4m 1 {kubelet ose70.rh7} spec.containers{busybox-nfs-pod} Started Started with docker id 346d432e5a48
위 화면과 같이 두 컨테이너 모두 백엔드의 동일한 NFS 마운트에 연결된 동일한 스토리지 클레임을 사용하고 있습니다.