Tag - k8s

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