1
1
---
2
- title : 用节点亲和性把 Pods 分配到节点
2
+ title : 用节点亲和性把 Pod 分配到节点
3
3
min-kubernetes-server-version : v1.10
4
4
content_type : task
5
- weight : 120
5
+ weight : 160
6
6
---
7
7
<!--
8
8
title: Assign Pods to Nodes using Node Affinity
9
9
min-kubernetes-server-version: v1.10
10
10
content_type: task
11
- weight: 120
11
+ weight: 160
12
12
-->
13
13
14
14
<!-- overview -->
@@ -29,19 +29,22 @@ Kubernetes cluster.
29
29
30
30
<!--
31
31
## Add a label to a node
32
-
33
- 1. List the nodes in your cluster, along with their labels:
34
32
-->
35
33
## 给节点添加标签
36
34
35
+ <!--
36
+ 1. List the nodes in your cluster, along with their labels:
37
+ -->
37
38
1 . 列出集群中的节点及其标签:
38
39
39
40
``` shell
40
41
kubectl get nodes --show-labels
41
42
```
43
+
42
44
< ! --
43
45
The output is similar to this:
44
46
-->
47
+
45
48
输出类似于此:
46
49
47
50
```
@@ -50,23 +53,26 @@ Kubernetes cluster.
50
53
worker1 Ready < none> 1d v1.13.0 ...,kubernetes.io/hostname=worker1
51
54
worker2 Ready < none> 1d v1.13.0 ...,kubernetes.io/hostname=worker2
52
55
```
53
- < ! --
54
- 1. Chose one of your nodes, and add a label to it:
55
- -->
56
- 1. 选择一个节点,给它添加一个标签:
56
+
57
+ < ! --
58
+ 1. Choose one of your nodes, and add a label to it:
59
+ -->
60
+ 2. 选择一个节点,给它添加一个标签:
57
61
58
62
` ` ` shell
59
63
kubectl label nodes < your-node-name> disktype=ssd
60
64
` ` `
61
- < ! --
62
- where ` < your-node-name> ` is the name of your chosen node.
63
65
64
- 1. Verify that your chosen node has a ` disktype=ssd` label:
66
+ < ! --
67
+ where ` < your-node-name> ` is the name of your chosen node.
65
68
-->
66
69
67
70
其中 ` < your-node-name> ` 是你所选节点的名称。
68
71
69
- 2. 验证你所选节点具有 ` disktype=ssd` 标签:
72
+ < ! --
73
+ 1. Verify that your chosen node has a ` disktype=ssd` label:
74
+ -->
75
+ 3. 验证你所选节点具有 ` disktype=ssd` 标签:
70
76
71
77
` ` ` shell
72
78
kubectl get nodes --show-labels
@@ -75,6 +81,7 @@ Kubernetes cluster.
75
81
< ! --
76
82
The output is similar to this:
77
83
-->
84
+
78
85
输出类似于此:
79
86
80
87
```
@@ -85,9 +92,10 @@ Kubernetes cluster.
85
92
```
86
93
87
94
< ! --
88
- In the preceding output, you can see that the ` worker0` node has a
89
- ` disktype=ssd` label.
95
+ In the preceding output, you can see that the ` worker0` node has a
96
+ ` disktype=ssd` label.
90
97
-->
98
+
91
99
在前面的输出中,可以看到 ` worker0` 节点有一个 ` disktype=ssd` 标签。
92
100
93
101
< ! --
@@ -113,18 +121,19 @@ This means that the pod will get scheduled only on a node that has a `disktype=s
113
121
kubectl apply -f https://k8s.io/examples/pods/pod-nginx-required-affinity.yaml
114
122
` ` `
115
123
116
- < ! --
117
- 1. Verify that the pod is running on your chosen node:
118
- -->
119
- 1 . 验证 pod 已经在所选节点上运行:
124
+ < ! --
125
+ 1. Verify that the pod is running on your chosen node:
126
+ -->
127
+ 2 . 验证 Pod 已经在所选节点上运行:
120
128
121
129
` ` ` shell
122
130
kubectl get pods --output=wide
123
131
` ` `
124
132
125
- < ! --
133
+ < ! --
126
134
The output is similar to this:
127
- -->
135
+ -->
136
+
128
137
输出类似于此:
129
138
130
139
```
@@ -140,8 +149,8 @@ This means that the pod will prefer a node that has a `disktype=ssd` label.
140
149
-->
141
150
# # 使用首选的节点亲和性调度 Pod {#schedule-a-Pod-using-preferred-node-affinity}
142
151
143
- 本清单描述了一个Pod ,它有一个节点亲和性设置 ` preferredDuringSchedulingIgnoredDuringExecution` ,` disktype: ssd` 。
144
- 这意味着 pod 将首选具有 ` disktype=ssd` 标签的节点。
152
+ 本清单描述了一个 Pod ,它有一个节点亲和性设置 ` preferredDuringSchedulingIgnoredDuringExecution` ,` disktype: ssd` 。
153
+ 这意味着 Pod 将首选具有 ` disktype=ssd` 标签的节点。
145
154
146
155
{{< codenew file=" pods/pod-nginx-preferred-affinity.yaml" > }}
147
156
@@ -155,10 +164,10 @@ This means that the pod will prefer a node that has a `disktype=ssd` label.
155
164
kubectl apply -f https://k8s.io/examples/pods/pod-nginx-preferred-affinity.yaml
156
165
` ` `
157
166
158
- < ! --
159
- 1. Verify that the pod is running on your chosen node:
160
- -->
161
- 1 . 验证 pod 是否在所选节点上运行:
167
+ < ! --
168
+ 1. Verify that the pod is running on your chosen node:
169
+ -->
170
+ 2 . 验证 Pod 是否在所选节点上运行:
162
171
163
172
` ` ` shell
164
173
kubectl get pods --output=wide
@@ -167,6 +176,7 @@ This means that the pod will prefer a node that has a `disktype=ssd` label.
167
176
< ! --
168
177
The output is similar to this:
169
178
-->
179
+
170
180
输出类似于此:
171
181
172
182
```
@@ -182,5 +192,4 @@ This means that the pod will prefer a node that has a `disktype=ssd` label.
182
192
Learn more about
183
193
[Node Affinity](/docs/concepts/scheduling-eviction/assign-pod-node/# node-affinity).
184
194
-->
185
- 进一步了解
186
- [节点亲和性](/zh-cn/docs/concepts/scheduling-eviction/assign-pod-node/# node-affinity).
195
+ 进一步了解[节点亲和性](/zh-cn/docs/concepts/scheduling-eviction/assign-pod-node/# node-affinity)。
0 commit comments