Node节点添加标签
[root@node1 work]# kubectl label nodes node1 node=master --overwrite node/node1 labeled [root@node1 work]# kubectl label nodes node2 node=master --overwrite node/node2 labeled [root@node1 work]# kubectl label nodes node3 node=master --overwrite node/node3 labeled [root@node1 work]# kubectl get nodes --show-labels NAME STATUS ROLES AGE VERSION LABELS node1 Ready <none> 5d18h v1.12.0-rc.2 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=node1,node=master node2 Ready <none> 5d18h v1.12.0-rc.2 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=node2,node=master node3 Ready <none> 5d18h v1.12.0-rc.2 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=node3,node=master
编排文件
[root@node1 work]# cat nginx.yaml apiVersion: extensions/v1beta1 kind: Deployment metadata: name: dep-staff-nginx namespace: default spec: replicas: 3 template: metadata: labels: name: staff-nginx spec: containers: - name: staff-nginx image: nginx:1.7.9 imagePullPolicy: IfNotPresent env: - name: TZ value: "Asia/Shanghai" ports: - name: tcp80 containerPort: 80 nodeSelector: node: "master" --- kind: Service apiVersion: v1 metadata: name: staff-proxy-service labels: name: staff-proxy-service spec: type: NodePort selector: name: staff-nginx ports: - name: tcp80 port: 80 targetPort: 80 nodePort: 30080
参考链接
https://k8smeetup.github.io/docs/concepts/configuration/assign-pod-node/