K8S對node新增label,並根據label篩選節點
阿新 • • 發佈:2019-02-11
某些特殊情況下,需要將某些服務固定在一臺宿主機上,K8S也適應這種方式,下面以mongo為例,來看看如何實現的:
kubectl label nodes kube-nodenode=kube-nodekubectl get node-a -l "node=kube-node"
pod或者rc的配置項中新增如下配置:
nodeSelector:
node: kube-node4
如mongo啟動的rc檔案
apiVersion: v1 kind: ReplicationController metadata: name: mongo spec: replicas: 1 template: metadata: labels: run: mongo spec: containers: - name: mongo image: daocloud.io/library/mongo:3.2.4 ports: - containerPort: 27017 volumeMounts: - mountPath: /data/db name: mongo volumes: [{"name":"mongo","hostPath":{"path":"/root/volumes/mongo"}}] nodeSelector: node: kube-node4