Tag - kubernetes

Docker kubernetes 容器    2017-04-28 16:32:19    37

最近刚刚入手研究kubernetes,运行容器的时候,发现一直处于ContainerCreating状态,悲了个催,刚入手就遇到了点麻烦,下面来讲讲如何查找问题及解决的

运行容器命令:

  1. [root@master-149 ~]# kubectl run my-alpine --image=alpine --replicas=2 ping www.baidu.com

查看pods状态

  1. [root@master-149 ~]# kubectl get pods
  2. NAME READY STATUS RESTARTS AGE
  3. my-alpine-2150523991-knzcx 0/1 ContainerCreating 0 6m
  4. my-alpine-2150523991-lmvv5 0/1 ContainerCreating 0 6m

一直处于ContainerCreating状态,开始查找原因
执行如下命令:

  1. [root@master-149 ~]# kubectl describe pod my-alpine
  2. Name: my-alpine-2150523991-knzcx
  3. Namespace: default
  4. Node: node-150/192.168.10.150
  5. Start Time: Sat, 19 Nov 2016 18:20:52 +0800
  6. Labels: pod-template-hash=2150523991,run=my-alpine
  7. Status: Pending
  8. IP:
  9. Controllers: ReplicaSet/my-alpine-2150523991
  10. Containers:
  11. my-alpine:
  12. Container ID:
  13. Image: alpine
  14. Image ID:
  15. Port:
  16. Args:
  17. ping
  18. w
Docker k8s kubernetes mongo 容器    2017-03-26 21:20:51    8

某些特殊情况下,需要将某些服务固定在一台宿主机上,K8S也适应这种方式,下面以mongo为例,来看看如何实现的:

  1. kubectl label nodes kube-node node=kube-node
  2. kubectl get node -a -l "node=kube-node"

pod或者rc的配置项中添加如下配置:

  1. nodeSelector:
  2. node: kube-node4

如mongo启动的rc文件

  1. apiVersion: v1
  2. kind: ReplicationController
  3. metadata:
  4. name: mongo
  5. spec:
  6. replicas: 1
  7. template:
  8. metadata:
  9. labels:
  10. run: mongo
  11. spec:
  12. containers:
  13. - name: mongo
  14. image: daocloud.io/library/mongo:3.2.4
  15. ports:
  16. - containerPort: 27017
  17. volumeMounts:
  18. - mountPath: /data/db
  19. name: mongo
  20. volumes: [{"name":"mongo","hostPath":{"path":"/root/volumes/mongo"}}]
  21. nodeSelector:
  22. node: kube-node4

by 刘迎光@萤火虫工作室
OpenBI交流群:495266201
MicroService 微服务交流群:217722918
mail: liuyg#liuyingguang.cn
博主首页(==防止爬虫==):http://blog.liuyingguang.cn