@@ -3,6 +3,13 @@ title: 创建静态 Pod
3
3
weight : 170
4
4
content_type : task
5
5
---
6
+ <!--
7
+ reviewers:
8
+ - jsafrane
9
+ title: Create static Pods
10
+ weight: 170
11
+ content_type: task
12
+ -->
6
13
7
14
<!-- overview -->
8
15
@@ -14,9 +21,8 @@ Unlike Pods that are managed by the control plane (for example, a
14
21
{{< glossary_tooltip text="Deployment" term_id="deployment" >}});
15
22
instead, the kubelet watches each static Pod (and restarts it if it fails).
16
23
-->
17
-
18
24
** 静态 Pod** 在指定的节点上由 kubelet 守护进程直接管理,不需要
19
- {{< glossary_tooltip text="API 服务器" term_id="kube-apiserver" >}} 监管。
25
+ {{< glossary_tooltip text="API 服务器" term_id="kube-apiserver" >}}监管。
20
26
与由控制面管理的 Pod(例如,{{< glossary_tooltip text="Deployment" term_id="deployment" >}})
21
27
不同;kubelet 监视每个静态 Pod(在它失败之后重新启动)。
22
28
@@ -48,7 +54,6 @@ instead.
48
54
替代这种方式。
49
55
{{< /note >}}
50
56
51
-
52
57
{{< note >}}
53
58
<!--
54
59
The `spec` of a static Pod cannot refer to other API objects
@@ -84,9 +89,8 @@ You can configure a static Pod with either a [file system hosted configuration f
84
89
-->
85
90
## 创建静态 Pod {#static-pod-creation}
86
91
87
- 可以通过[ 文件系统上的配置文件] ( /zh-cn/docs/tasks/configure-pod-container/static-pod/#configuration-files )
88
- 或者 [ Web 网络上的配置文件] ( /zh-cn/docs/tasks/configure-pod-container/static-pod/#pods-created-via-http )
89
- 来配置静态 Pod。
92
+ 可以通过[ 文件系统上的配置文件] ( /zh-cn/docs/tasks/configure-pod-container/static-pod/#configuration-files ) 或者
93
+ [ Web 网络上的配置文件] ( /zh-cn/docs/tasks/configure-pod-container/static-pod/#pods-created-via-http ) 来配置静态 Pod。
90
94
91
95
<!--
92
96
### Filesystem-hosted static Pod manifest {#configuration-files}
@@ -101,8 +105,8 @@ For example, this is how to start a simple web server as a static Pod:
101
105
### 文件系统上的静态 Pod 声明文件 {#configuration-files}
102
106
103
107
声明文件是标准的 Pod 定义文件,以 JSON 或者 YAML 格式存储在指定目录。路径设置在
104
- [ Kubelet 配置文件] ( /zh-cn/docs/reference/config-api/kubelet-config.v1beta1/ )
105
- 的 ` staticPodPath: <目录> ` 字段,kubelet 会定期的扫描这个文件夹下的 YAML/JSON
108
+ [ Kubelet 配置文件] ( /zh-cn/docs/reference/config-api/kubelet-config.v1beta1/ ) 的
109
+ ` staticPodPath: <目录> ` 字段,kubelet 会定期的扫描这个文件夹下的 YAML/JSON
106
110
文件来创建/删除静态 Pod。
107
111
注意 kubelet 扫描目录的时候会忽略以点开头的文件。
108
112
@@ -178,8 +182,8 @@ For example, this is how to start a simple web server as a static Pod:
178
182
or add the ` staticPodPath: <the directory>` field in the
179
183
[kubelet configuration file](/docs/reference/config-api/kubelet-config.v1beta1/).
180
184
-->
181
- 或者在 [Kubelet 配置文件](/zh-cn/docs/reference/config-api/kubelet-config.v1beta1/)
182
- 中添加 ` staticPodPath: <目录>` 字段。
185
+ 或者在 [Kubelet 配置文件](/zh-cn/docs/reference/config-api/kubelet-config.v1beta1/)中添加
186
+ ` staticPodPath: <目录>` 字段。
183
187
184
188
< ! --
185
189
4. Restart the kubelet. On Fedora, you would run:
@@ -242,7 +246,7 @@ JSON/YAML 格式的 Pod 定义文件。
242
246
2. Configure the kubelet on your selected node to use this web manifest by running it with ` --manifest-url=< manifest-url> ` . On Fedora, edit ` /etc/kubernetes/kubelet` to include this line:
243
247
-->
244
248
2. 通过在选择的节点上使用 ` --manifest-url=< manifest-url> ` 配置运行 kubelet。
245
- 在 Fedora 添加下面这行到 ` /etc/kubernetes/kubelet` :
249
+ 在 Fedora 添加下面这行到 ` /etc/kubernetes/kubelet` :
246
250
247
251
` ` `
248
252
KUBELET_ARGS=" --cluster-dns=10.254.0.10 --cluster-domain=kube.local --manifest-url=<manifest-url>"
@@ -325,11 +329,9 @@ static-web 1/1 Running 0 2m
325
329
326
330
{{< note > }}
327
331
< ! --
328
- Make sure the kubelet has permission to create the mirror Pod in the API server. If not, the creation request is rejected by the API server. See [Pod Security admission](/docs/concepts/security/pod-security-admission) and [PodSecurityPolicy](/docs/concepts/security/pod-security-policy/).
332
+ Make sure the kubelet has permission to create the mirror Pod in the API server. If not, the creation request is rejected by the API server.
329
333
-->
330
334
要确保 kubelet 在 API 服务上有创建镜像 Pod 的权限。如果没有,创建请求会被 API 服务拒绝。
331
- 参阅 [Pod 安全性准入](/zh-cn/docs/concepts/security/pod-security-admission/)和
332
- [Pod 安全策略](/zh-cn/docs/concepts/security/pod-security-policy/)。
333
335
{{< /note > }}
334
336
335
337
< ! --
@@ -401,7 +403,7 @@ CONTAINER IMAGE CREATED STATE
401
403
402
404
The running kubelet periodically scans the configured directory (` /etc/kubernetes/manifests` in our example) for changes and adds/removes Pods as files appear/disappear in this directory.
403
405
-->
404
- # # 动态增加和删除静态 Pod
406
+ # # 动态增加和删除静态 Pod {#dynamic-addition-and-removal-of-static-pods}
405
407
406
408
运行中的 kubelet 会定期扫描配置的目录(比如例子中的 ` /etc/kubernetes/manifests` 目录)中的变化,
407
409
并且根据文件中出现/消失的 Pod 来添加/删除 Pod。
@@ -411,11 +413,11 @@ The running kubelet periodically scans the configured directory (`/etc/kubernete
411
413
# This assumes you are using filesystem-hosted static Pod configuration
412
414
# Run these commands on the node where the kubelet is running
413
415
#
414
- mv /etc/kubelet.d /static-web.yaml /tmp
416
+ mv /etc/kubernetes/manifests /static-web.yaml /tmp
415
417
sleep 20
416
418
crictl ps
417
419
# You see that no nginx container is running
418
- mv /tmp/static-web.yaml /etc/kubelet.d /
420
+ mv /tmp/static-web.yaml /etc/kubernetes/manifests /
419
421
sleep 20
420
422
crictl ps
421
423
` ` `
0 commit comments