Skip to content

Commit 69e0d68

Browse files
authored
Merge pull request #38929 from windsonsea/stapod
[zh] sync static-pod.md
2 parents 1754a9e + 9130741 commit 69e0d68

File tree

1 file changed

+41
-25
lines changed

1 file changed

+41
-25
lines changed

content/zh-cn/docs/tasks/configure-pod-container/static-pod.md

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,6 @@ For example, this is how to start a simple web server as a static Pod:
130130

131131
<!--
132132
2. Choose a directory, say `/etc/kubernetes/manifests` and place a web server Pod definition there, for example `/etc/kubernetes/manifests/static-web.yaml`:
133-
134-
```shell
135-
# Run this command on the node where kubelet is running
136-
mkdir /etc/kubelet.d/
137-
cat <<EOF >/etc/kubelet.d/static-web.yaml
138-
apiVersion: v1
139-
kind: Pod
140-
metadata:
141-
name: static-web
142-
labels:
143-
role: myrole
144-
spec:
145-
containers:
146-
- name: web
147-
image: nginx
148-
ports:
149-
- name: web
150-
containerPort: 80
151-
protocol: TCP
152-
EOF
153133
-->
154134
2. 选择一个目录,比如在 `/etc/kubernetes/manifests` 目录来保存 Web 服务 Pod 的定义文件,例如
155135
`/etc/kubernetes/manifests/static-web.yaml`
@@ -230,7 +210,7 @@ JSON/YAML 格式的 Pod 定义文件。
230210
<!--
231211
1. Create a YAML file and store it on a web server so that you can pass the URL of that file to the kubelet.
232212
-->
233-
1. 创建一个 YAML 文件,并保存在 web 服务上,为 kubelet 生成一个 URL
213+
1. 创建一个 YAML 文件,并保存在 Web 服务器上,这样你就可以将该文件的 URL 传递给 kubelet
234214
235215
```yaml
236216
apiVersion: v1
@@ -286,8 +266,6 @@ You can view running containers (including static Pods) by running (on the node)
286266
# Run this command on the node where the kubelet is running
287267
crictl ps
288268
```
289-
290-
The output might be something like:
291269
-->
292270
## 观察静态 Pod 的行为 {#behavior-of-static-pods}
293271
@@ -405,6 +383,28 @@ CONTAINER IMAGE CREATED STATE
405383
89db4553e1eeb docker.io/library/nginx@sha256:... 19 seconds ago Running web 1 34533c6729106
406384
```
407385
386+
<!--
387+
Once you identify the right container, you can get the logs for that container with `crictl`:
388+
-->
389+
一旦你找到合适的容器,你就可以使用 `crictl` 获取该容器的日志。
390+
391+
```shell
392+
# 在容器运行所在的节点上执行以下命令
393+
crictl logs <container_id>
394+
```
395+
396+
```console
397+
10.240.0.48 - - [16/Nov/2022:12:45:49 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.47.0" "-"
398+
10.240.0.48 - - [16/Nov/2022:12:45:50 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.47.0" "-"
399+
10.240.0.48 - - [16/Nove/2022:12:45:51 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.47.0" "-"
400+
```
401+
402+
<!--
403+
To find more about how to debug using `crictl`, please visit [_Debugging Kubernetes nodes with crictl_](https://kubernetes.io/docs/tasks/debug/debug-cluster/crictl/)
404+
-->
405+
若要找到如何使用 `crictl` 进行调试的更多信息,
406+
请访问[使用 crictl 对 Kubernetes 节点进行调试](/zh-cn/docs/tasks/debug/debug-cluster/crictl/)。
407+
408408
<!--
409409
## Dynamic addition and removal of static pods
410410
@@ -418,7 +418,7 @@ The running kubelet periodically scans the configured directory (`/etc/kubernete
418418
<!--
419419
```shell
420420
# This assumes you are using filesystem-hosted static Pod configuration
421-
# Run these commands on the node where the kubelet is running
421+
# Run these commands on the node where the container is running
422422
#
423423
mv /etc/kubernetes/manifests/static-web.yaml /tmp
424424
sleep 20
@@ -431,7 +431,7 @@ crictl ps
431431
-->
432432
```shell
433433
# 这里假定你在用主机文件系统上的静态 Pod 配置文件
434-
# 在 kubelet 运行的节点上执行以下命令
434+
# 在容器运行所在的节点上执行以下命令
435435
mv /etc/kubernetes/manifests/static-web.yaml /tmp
436436
sleep 20
437437
crictl ps
@@ -446,3 +446,19 @@ CONTAINER IMAGE CREATED STATE
446446
f427638871c35 docker.io/library/nginx@sha256:... 19 seconds ago Running web 1 34533c6729106
447447
```
448448
449+
## {{% heading "whatsnext" %}}
450+
451+
<!--
452+
* [Generate static Pod manifests for control plane components](/docs/reference/setup-tools/kubeadm/implementation-details/#generate-static-pod-manifests-for-control-plane-components)
453+
* [Generate static Pod manifest for local etcd](/docs/reference/setup-tools/kubeadm/implementation-details/#generate-static-pod-manifest-for-local-etcd)
454+
* [Debugging Kubernetes nodes with `crictl`](/docs/tasks/debug/debug-cluster/crictl/)
455+
* [Learn more about `crictl`](https://github.com/kubernetes-sigs/cri-tools).
456+
* [Map `docker` CLI commands to `crictl`](/docs/reference/tools/map-crictl-dockercli/).
457+
* [Set up etcd instances as static pods managed by a kubelet](/docs/setup/production-environment/tools/kubeadm/setup-ha-etcd-with-kubeadm/)
458+
-->
459+
* [为控制面组件生成静态 Pod 清单](/zh-cn/docs/reference/setup-tools/kubeadm/implementation-details/#generate-static-pod-manifests-for-control-plane-components)
460+
* [为本地 etcd 生成静态 Pod 清单](/zh-cn/docs/reference/setup-tools/kubeadm/implementation-details/#generate-static-pod-manifest-for-local-etcd)
461+
* [使用 `crictl` 对 Kubernetes 节点进行调试](/docs/tasks/debug/debug-cluster/crictl/)
462+
* 更多细节请参阅 [`crictl`](https://github.com/kubernetes-sigs/cri-tools)
463+
* [从 `docker` CLI 命令映射到 `crictl`](/zh-cn/docs/reference/tools/map-crictl-dockercli/)
464+
* [将 etcd 实例设置为由 kubelet 管理的静态 Pod](/zh-cn/docs/setup/production-environment/tools/kubeadm/setup-ha-etcd-with-kubeadm/)

0 commit comments

Comments
 (0)