污点和宽容
Taints and Toleration
我正在练习 kubernetes taints,我污染了我的节点,而不是像这样进行部署:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.15.4
ports:
- containerPort: 80
tolerations:
- key: "test"
operator: "Equal"
value: "blue"
effect: "NoSchedule"
kubectl 描述节点 knode2 :
Name: knode2
Roles: <none>
Labels: beta.kubernetes.io/arch=amd64
beta.kubernetes.io/os=linux
kubernetes.io/arch=amd64
kubernetes.io/hostname=knode2
kubernetes.io/os=linux
testing=test
Annotations: kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
node.alpha.kubernetes.io/ttl: 0
projectcalico.org/IPv4Address: **********
projectcalico.org/IPv4IPIPTunnelAddr: ********
volumes.kubernetes.io/controller-managed-attach-detach: true
CreationTimestamp: Tue, 27 Oct 2020 17:23:47 +0200
Taints: test=blue:NoSchedule
但是当我部署这个 yaml 文件时,pods 不仅会转到那个受污染的节点。
这是为什么?
污点和容忍度共同确保 pods 不会被调度到不合适的节点上。这与您打算做的完全相反。
您可以使用 NodeSelector or NodeAffinity.[=12= 将 Pod 限制为只能在特定节点上 运行,或者更喜欢在特定节点上 运行 ]
节点选择器示例
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
containers:
- name: nginx
image: nginx
imagePullPolicy: IfNotPresent
nodeSelector:
disktype: ssd
节点亲和力在概念上类似于 nodeSelector -- 它允许您根据节点上的标签来限制您的 pod 有资格被调度到哪些节点上。
我正在练习 kubernetes taints,我污染了我的节点,而不是像这样进行部署:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.15.4
ports:
- containerPort: 80
tolerations:
- key: "test"
operator: "Equal"
value: "blue"
effect: "NoSchedule"
kubectl 描述节点 knode2 :
Name: knode2
Roles: <none>
Labels: beta.kubernetes.io/arch=amd64
beta.kubernetes.io/os=linux
kubernetes.io/arch=amd64
kubernetes.io/hostname=knode2
kubernetes.io/os=linux
testing=test
Annotations: kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
node.alpha.kubernetes.io/ttl: 0
projectcalico.org/IPv4Address: **********
projectcalico.org/IPv4IPIPTunnelAddr: ********
volumes.kubernetes.io/controller-managed-attach-detach: true
CreationTimestamp: Tue, 27 Oct 2020 17:23:47 +0200
Taints: test=blue:NoSchedule
但是当我部署这个 yaml 文件时,pods 不仅会转到那个受污染的节点。 这是为什么?
污点和容忍度共同确保 pods 不会被调度到不合适的节点上。这与您打算做的完全相反。
您可以使用 NodeSelector or NodeAffinity.[=12= 将 Pod 限制为只能在特定节点上 运行,或者更喜欢在特定节点上 运行 ]
节点选择器示例
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
containers:
- name: nginx
image: nginx
imagePullPolicy: IfNotPresent
nodeSelector:
disktype: ssd
节点亲和力在概念上类似于 nodeSelector -- 它允许您根据节点上的标签来限制您的 pod 有资格被调度到哪些节点上。