如何将 Deployment 分配给特定的节点池
How to assign a Deployment to a specific Node Pool
我是 Kubernetes 的新手,能够设置包括入口在内的工作流。
如何指定哪些部署(不是 pods)进入特定节点池?
此外,命名空间对节点也有影响吗?
参考这个 link:https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
containers:
- name: nginx
image: nginx
imagePullPolicy: IfNotPresent
nodeSelector:
disktype: ssd
另一种选择是使用亲和力:
apiVersion: v1
kind: Pod
metadata:
name: with-node-affinity
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/e2e-az-name
operator: In
values:
- e2e-az1
- e2e-az2
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: another-node-label-key
operator: In
values:
- another-node-label-value
containers:
- name: with-node-affinity
image: k8s.gcr.io/pause:2.0
节点独立于名称空间。您可以在部署规范部分指定的 pod 模板中指定节点亲和性规则。您只能将 pods 分配给特定节点,事实上这就是部署创建 pods 的原因,因此仅将 pods 分配给节点是有意义的。
我是 Kubernetes 的新手,能够设置包括入口在内的工作流。
如何指定哪些部署(不是 pods)进入特定节点池?
此外,命名空间对节点也有影响吗?
参考这个 link:https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
spec:
containers:
- name: nginx
image: nginx
imagePullPolicy: IfNotPresent
nodeSelector:
disktype: ssd
另一种选择是使用亲和力:
apiVersion: v1
kind: Pod
metadata:
name: with-node-affinity
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/e2e-az-name
operator: In
values:
- e2e-az1
- e2e-az2
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: another-node-label-key
operator: In
values:
- another-node-label-value
containers:
- name: with-node-affinity
image: k8s.gcr.io/pause:2.0
节点独立于名称空间。您可以在部署规范部分指定的 pod 模板中指定节点亲和性规则。您只能将 pods 分配给特定节点,事实上这就是部署创建 pods 的原因,因此仅将 pods 分配给节点是有意义的。