28.2.5. Pod 생성
포드 정의 파일 또는 템플릿 파일을 사용하여 포드를 정의할 수 있습니다. 다음은 단일 컨테이너를 생성하고 읽기-쓰기 액세스를 위해 NFS 볼륨을 마운트하는 Pod 사양입니다.
예 28.3. Pod 오브젝트 정의
apiVersion: v1
kind: Pod
metadata:
name: hello-openshift-nfs-pod
labels:
name: hello-openshift-nfs-pod
spec:
containers:
- name: hello-openshift-nfs-pod
image: openshift/hello-openshift
ports:
- name: web
containerPort: 80
volumeMounts:
- name: nfsvol
mountPath: /usr/share/nginx/html
securityContext:
supplementalGroups: [100003]
privileged: false
volumes:
- name: nfsvol
persistentVolumeClaim:
claimName: nfs-pvc
Pod 정의를 파일에 저장하고(예: nfs.yaml ) Pod를 생성합니다.
# oc create -f nfs.yaml
pod "hello-openshift-nfs-pod" created
Pod가 생성되었는지 확인합니다.
# oc get pods
NAME READY STATUS RESTARTS AGE
hello-openshift-nfs-pod 1/1 Running 0 4s
자세한 내용은 oc describe pod 명령에 표시됩니다.
[root@ose70 nfs]# oc describe pod hello-openshift-nfs-pod
Name: hello-openshift-nfs-pod
Namespace: default
Image(s): fedora/S3
Node: ose70.rh7/192.168.234.148
Start Time: Mon, 21 Mar 2016 09:59:47 -0400
Labels: name=hello-openshift-nfs-pod
Status: Running
Reason:
Message:
IP: 10.1.0.4
Replication Controllers: <none>
Containers:
hello-openshift-nfs-pod:
Container ID: docker://a3292104d6c28d9cf49f440b2967a0fc5583540fc3b062db598557b93893bc6f
Image: fedora/S3
Image ID: docker://403d268c640894cbd76d84a1de3995d2549a93af51c8e16e89842e4c3ed6a00a
QoS Tier:
cpu: BestEffort
memory: BestEffort
State: Running
Started: Mon, 21 Mar 2016 09:59:49 -0400
Ready: True
Restart Count: 0
Environment Variables:
Conditions:
Type Status
Ready True
Volumes:
nfsvol:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: nfs-pvc
ReadOnly: false
default-token-a06zb:
Type: Secret (a secret that should populate this volume)
SecretName: default-token-a06zb
Events:
FirstSeen LastSeen Count From SubobjectPath Reason Message
───────── ──────── ───── ──── ───────────── ────── ───────
4m 4m 1 {scheduler } Scheduled Successfully assigned hello-openshift-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 866a37108041
4m 4m 1 {kubelet ose70.rh7} implicitly required container POD Started Started with docker id 866a37108041
4m 4m 1 {kubelet ose70.rh7} spec.containers{hello-openshift-nfs-pod} Pulled Container image "fedora/S3" already present on machine
4m 4m 1 {kubelet ose70.rh7} spec.containers{hello-openshift-nfs-pod} Created Created with docker id a3292104d6c2
4m 4m 1 {kubelet ose70.rh7} spec.containers{hello-openshift-nfs-pod} Started Started with docker id a3292104d6c2
oc get pod <name> -o yaml 명령에 표시된 Pod, 사용자 및 그룹 ID, SELinux 레이블 등을 인증하는 데 사용되는 SCC를 포함하여 더 많은 내부 정보가 있습니다.
[root@ose70 nfs]# oc get pod hello-openshift-nfs-pod -o yaml
apiVersion: v1
kind: Pod
metadata:
annotations:
openshift.io/scc: restricted
creationTimestamp: 2016-03-21T13:59:47Z
labels:
name: hello-openshift-nfs-pod
name: hello-openshift-nfs-pod
namespace: default
resourceVersion: "2814411"
selflink: /api/v1/namespaces/default/pods/hello-openshift-nfs-pod
uid: 2c22d2ea-ef6d-11e5-adc7-000c2900f1e3
spec:
containers:
- image: fedora/S3
imagePullPolicy: IfNotPresent
name: hello-openshift-nfs-pod
ports:
- containerPort: 80
name: web
protocol: TCP
resources: {}
securityContext:
privileged: false
terminationMessagePath: /dev/termination-log
volumeMounts:
- mountPath: /usr/share/S3/html
name: nfsvol
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-a06zb
readOnly: true
dnsPolicy: ClusterFirst
host: ose70.rh7
imagePullSecrets:
- name: default-dockercfg-xvdew
nodeName: ose70.rh7
restartPolicy: Always
securityContext:
supplementalGroups:
- 100003
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
volumes:
- name: nfsvol
persistentVolumeClaim:
claimName: nfs-pvc
- name: default-token-a06zb
secret:
secretName: default-token-a06zb
status:
conditions:
- lastProbeTime: null
lastTransitionTime: 2016-03-21T13:59:49Z
status: "True"
type: Ready
containerStatuses:
- containerID: docker://a3292104d6c28d9cf49f440b2967a0fc5583540fc3b062db598557b93893bc6f
image: fedora/S3
imageID: docker://403d268c640894cbd76d84a1de3995d2549a93af51c8e16e89842e4c3ed6a00a
lastState: {}
name: hello-openshift-nfs-pod
ready: true
restartCount: 0
state:
running:
startedAt: 2016-03-21T13:59:49Z
hostIP: 192.168.234.148
phase: Running
podIP: 10.1.0.4
startTime: 2016-03-21T13:59:47Z