最近在学习kubernetes的单pod多容器,找了几个实例,自己测试【单pod双容器】,总是只有一个running,另一个一直在created和started,看了日志没发现什么问题。
而且配置是按照官网的修改的,不知是yaml写错了(大概率),还是kube需要修改什么配置,如有哪位大神测试成功,麻烦指点一二。
官网的例子:
apiVersion: v1 kind: Pod metadata: name: www spec: containers: - name: nginx image: nginx volumeMounts: - mountPath: /srv/www name: www-data readOnly: true - name: git-monitor image: kubernetes/git-monitor env: - name: GIT_REPO value: http://github.com/some/repo.git volumeMounts: - mountPath: /data name: www-data volumes: - name: www-data emptyDir: {} |
[root@www pod_nginx_redis_kube]# cat nginx_redis_pod_test.json --- apiVersion: v1 kind: Pod metadata: name: www spec: containers: - name: nginx image: www.perofu.com:7070/centos6.4_ip_nginx command: - "/etc/rc.local" - name: redis-1 image: www.perofu.com:7070/centos6.4_redis command: - "/etc/rc.local" [root@www pod_nginx_redis_kube]# /usr/bin/kubectl create -f nginx_redis_pod_test.json pods/www [root@www pod_nginx_redis_kube]# [root@www pod_nginx_redis_kube]# /usr/bin/kubectl get pod NAME READY STATUS RESTARTS AGE www 0/2 Pending 0 3s [root@www pod_nginx_redis_kube]# /usr/bin/kubectl get pod NAME READY STATUS RESTARTS AGE www 1/2 Running 8 3m [root@www pod_nginx_redis_kube]# /usr/bin/kubectl describe pod www Name: www Namespace: default Image(s): www.perofu.com:7070/centos6.4_ip_nginx,www.perofu.com:7070/centos6.4_redis Node: 192.168.16.240/192.168.16.240 Labels: <none> Status: Running Reason: Message: IP: 172.22.2.2 Replication Controllers: <none> Containers: nginx: Image: www.perofu.com:7070/centos6.4_ip_nginx State: Running Started: Thu, 21 Jan 2016 16:07:42 +0800 Ready: False Restart Count: 9 redis-1: Image: www.perofu.com:7070/centos6.4_redis State: Running Started: Thu, 21 Jan 2016 16:04:19 +0800 Ready: True Restart Count: 0 Conditions: Type Status Ready False Events: FirstSeen LastSeen Count From SubobjectPath Reason Message Thu, 21 Jan 2016 16:03:34 +0800 Thu, 21 Jan 2016 16:03:34 +0800 1 {scheduler } scheduled Successfully assigned www to 192.168.16.240 Thu, 21 Jan 2016 16:04:16 +0800 Thu, 21 Jan 2016 16:04:16 +0800 1 {kubelet 192.168.16.240} implicitly required container POD pulled Pod container image "gcr.io/google_containers/pause:0.8.0" already present on machine Thu, 21 Jan 2016 16:04:17 +0800 Thu, 21 Jan 2016 16:04:17 +0800 1 {kubelet 192.168.16.240} implicitly required container POD created Created with docker id c7884e18b3ff Thu, 21 Jan 2016 16:04:17 +0800 Thu, 21 Jan 2016 16:04:17 +0800 1 {kubelet 192.168.16.240} implicitly required container POD started Started with docker id c7884e18b3ff Thu, 21 Jan 2016 16:04:18 +0800 Thu, 21 Jan 2016 16:04:18 +0800 1 {kubelet 192.168.16.240} spec.containers{nginx} created Created with docker id ce71cdeddab3 Thu, 21 Jan 2016 16:04:18 +0800 Thu, 21 Jan 2016 16:04:18 +0800 1 {kubelet 192.168.16.240} spec.containers{nginx} started Started with docker id ce71cdeddab3 Thu, 21 Jan 2016 16:04:19 +0800 Thu, 21 Jan 2016 16:04:19 +0800 1 {kubelet 192.168.16.240} spec.containers{redis-1} created Created with docker id 15ca805a9e99 Thu, 21 Jan 2016 16:04:19 +0800 Thu, 21 Jan 2016 16:04:19 +0800 1 {kubelet 192.168.16.240} spec.containers{redis-1} started Started with docker id 15ca805a9e99 Thu, 21 Jan 2016 16:04:32 +0800 Thu, 21 Jan 2016 16:04:32 +0800 1 {kubelet 192.168.16.240} spec.containers{nginx} created Created with docker id edfacd145c9b Thu, 21 Jan 2016 16:04:32 +0800 Thu, 21 Jan 2016 16:04:32 +0800 1 {kubelet 192.168.16.240} spec.containers{nginx} started Started with docker id edfacd145c9b Thu, 21 Jan 2016 16:04:42 +0800 Thu, 21 Jan 2016 16:04:42 +0800 1 {kubelet 192.168.16.240} spec.containers{nginx} created Created with docker id 2cfb065965d2 Thu, 21 Jan 2016 16:04:42 +0800 Thu, 21 Jan 2016 16:04:42 +0800 1 {kubelet 192.168.16.240} spec.containers{nginx} started Started with docker id 2cfb065965d2
#查看日志:没发现问题
[root@www pod_nginx_redis_kube]# /usr/bin/kubectl logs www nginx [root@www pod_nginx_redis_kube]# |
望指点一二。