apiVersion: apps/v1 kind: Deployment metadata: name: health-check-deployment labels: app: health-check spec: replicas: 1 selector: matchLabels: app: health-check template: metadata: labels: app: health-check spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: node-role.kubernetes.io/master operator: Exists tolerations: - key: node-role.kubernetes.io/master operator: Exists effect: NoSchedule - key: node.kubernetes.io/unschedulable operator: Exists effect: NoSchedule containers: - name: check-status image: hub-pub.jdcloud.com/jdos/jdos-k8s-jiankong:v1.0.0-4b9258e imagePullPolicy: IfNotPresent #command: ["bash","-c","/root/health-chek/check-k8s.sh && sleep 100000"] volumeMounts: - mountPath: /root/.kube/config name: kubeconfig - mountPath: /usr/bin/kubectl name: kubectl-procedure - mountPath: /usr/bin/etcdctl name: etcdctl-procedure - mountPath: /etc/ssl/etcd/ssl/ name: etcd-certs-dir volumes: - name: kubeconfig hostPath: path: /etc/kubernetes/admin.conf type: File - name: kubectl-procedure hostPath: path: /usr/local/bin/kubectl type: File - name: etcdctl-procedure hostPath: path: /usr/local/bin/etcdctl type: File - name: etcd-certs-dir hostPath: path: /etc/ssl/etcd/ssl/ type: Directory
备注:1. affinity:
nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: node-role.kubernetes.io/master operator: Exists
配置节点亲和性,requiredDuringSchedulingIgnoredDuringExecution 代表强制调度,调度pod到已存在的master role的节点(也就是master节点)
2. 污点容忍
- key: node-role.kubernetes.io/master operator: Exists effect: NoSchedule - key: node.kubernetes.io/unschedulable operator: Exists effect: NoSchedule
容忍不可调度污点,以及master不可调度污点标签:Exists,name,kubernetes,deploy,亲和性,operator,master,key,污点 From: https://www.cnblogs.com/gsda/p/17175677.html