当前位置:  首页>> 技术小册>> Kubernets合辑5-Pod控制器

  1. apiVersion: v1
  2. kind: Pod
  3. metadata:
  4. name: pod-demo
  5. namespace: app
  6. labels:
  7. app: centos7
  8. release: stable
  9. environment: dev
  10. spec:
  11. containers:
  12. - name: centos
  13. image: harbor.od.com/public/centos:7
  14. command:
  15. - /bin/bash
  16. - -c
  17. - "sleep 3600"
  1. [root@hdss7-21 ~]# kubectl apply -f http://k8s-yaml.od.com/base_resource/pods/myapp.yaml
  2. [root@hdss7-21 ~]# kubectl get pod -o wide -n app
  3. NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
  4. pod-demo 1/1 Running 0 16s 172.7.22.2 hdss7-22.host.com <none> <none>
  5. [root@hdss7-21 ~]# kubectl exec pod-demo -n app -- ps uax
  6. USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
  7. root 1 0.0 0.0 4364 352 ? Ss 04:41 0:00 sleep 3600
  8. root 11 0.0 0.0 51752 1696 ? Rs 04:42 0:00 ps uax
  1. [root@hdss7-21 ~]# kubectl describe pod pod-demo -n app | tail
  2. Events:
  3. Type Reason Age From Message
  4. ---- ------ ---- ---- -------
  5. Normal Scheduled 3m46s default-scheduler Successfully assigned app/pod-demo to hdss7-22.host.com
  6. Normal Pulling 3m45s kubelet, hdss7-22.host.com Pulling image "harbor.od.com/public/centos:7"
  7. Normal Pulled 3m45s kubelet, hdss7-22.host.com Successfully pulled image "harbor.od.com/public/centos:7"
  8. Normal Created 3m45s kubelet, hdss7-22.host.com Created container centos
  9. Normal Started 3m45s kubelet, hdss7-22.host.com Started container centos

该分类下的相关小册推荐: