Merge pull request #48618 from my-git9/pp-18101
[zh-cn]sync and improve docker-cli-to-kubectl node-conformancepull/48641/head
commit
b0c21c2f61
|
@ -31,7 +31,7 @@ To run an nginx Deployment and expose the Deployment, see [kubectl create deploy
|
|||
<!--
|
||||
docker:
|
||||
-->
|
||||
使用 Docker 命令:
|
||||
使用 docker 命令:
|
||||
|
||||
```shell
|
||||
docker run -d --restart=always -e DOMAIN=cluster --name nginx-app -p 80:80 nginx
|
||||
|
@ -79,7 +79,7 @@ deployment.apps/nginx-app env updated
|
|||
<!--
|
||||
`kubectl` commands print the type and name of the resource created or mutated, which can then be used in subsequent commands. You can expose a new Service after a Deployment is created.
|
||||
-->
|
||||
`kubectl` 命令打印创建或突变资源的类型和名称,然后可以在后续命令中使用。部署后,你可以公开新服务。
|
||||
`kubectl` 命令打印创建或突变资源的类型和名称,然后可以在后续命令中使用。部署后,你可以公开新的 Service。
|
||||
{{< /note >}}
|
||||
|
||||
<!--
|
||||
|
@ -89,7 +89,7 @@ kubectl expose deployment nginx-app --port=80 --name=nginx-http
|
|||
```
|
||||
-->
|
||||
```shell
|
||||
# 通过服务公开端口
|
||||
# 通过 Service 公开端口
|
||||
kubectl expose deployment nginx-app --port=80 --name=nginx-http
|
||||
```
|
||||
```
|
||||
|
@ -101,14 +101,14 @@ By using kubectl, you can create a [Deployment](/docs/concepts/workloads/control
|
|||
-->
|
||||
在 kubectl 命令中,我们创建了一个 [Deployment](/zh-cn/docs/concepts/workloads/controllers/deployment/),
|
||||
这将保证有 N 个运行 nginx 的 Pod(N 代表 spec 中声明的副本数,默认为 1)。
|
||||
我们还创建了一个 [service](/zh-cn/docs/concepts/services-networking/service/),其选择算符与容器标签匹配。
|
||||
查看[使用服务访问集群中的应用程序](/zh-cn/docs/tasks/access-application-cluster/service-access-application-cluster)获取更多信息。
|
||||
我们还创建了一个 [Service](/zh-cn/docs/concepts/services-networking/service/),其选择算符与容器标签匹配。
|
||||
查看[使用 Service 访问集群中的应用程序](/zh-cn/docs/tasks/access-application-cluster/service-access-application-cluster)获取更多信息。
|
||||
|
||||
<!--
|
||||
By default images run in the background, similar to `docker run -d ...`. To run things in the foreground, use [`kubectl run`](/docs/reference/generated/kubectl/kubectl-commands/#run) to create pod:
|
||||
-->
|
||||
默认情况下镜像会在后台运行,与 `docker run -d ...` 类似,如果你想在前台运行,
|
||||
使用 [`kubectl run`](/docs/reference/generated/kubectl/kubectl-commands/#run) 在前台运行 Pod:
|
||||
使用 [`kubectl run`](/docs/reference/generated/kubectl/kubectl-commands/#run) 在前台运行 Pod:
|
||||
|
||||
```shell
|
||||
kubectl run [-i] [--tty] --attach <name> --image=<image>
|
||||
|
@ -139,7 +139,7 @@ To list what is currently running, see [kubectl get](/docs/reference/generated/k
|
|||
<!--
|
||||
docker:
|
||||
-->
|
||||
使用 Docker 命令:
|
||||
使用 docker 命令:
|
||||
|
||||
```shell
|
||||
docker ps -a
|
||||
|
@ -175,7 +175,7 @@ To attach a process that is already running in a container, see [kubectl attach]
|
|||
<!--
|
||||
docker:
|
||||
-->
|
||||
使用 Docker 命令:
|
||||
使用 docker 命令:
|
||||
|
||||
```shell
|
||||
docker ps
|
||||
|
@ -190,7 +190,10 @@ docker attach 55c103fa1296
|
|||
...
|
||||
```
|
||||
|
||||
<!--
|
||||
kubectl:
|
||||
-->
|
||||
使用 kubectl 命令:
|
||||
|
||||
```shell
|
||||
kubectl get pods
|
||||
|
@ -220,7 +223,7 @@ To execute a command in a container, see [kubectl exec](/docs/reference/generate
|
|||
<!--
|
||||
docker:
|
||||
-->
|
||||
使用 Docker 命令:
|
||||
使用 docker 命令:
|
||||
|
||||
```shell
|
||||
docker ps
|
||||
|
@ -264,14 +267,17 @@ To use interactive commands.
|
|||
<!--
|
||||
docker:
|
||||
-->
|
||||
使用 Docker 命令:
|
||||
使用 docker 命令:
|
||||
|
||||
```shell
|
||||
docker exec -ti 55c103fa1296 /bin/sh
|
||||
# exit
|
||||
```
|
||||
|
||||
<!--
|
||||
kubectl:
|
||||
-->
|
||||
使用 kubectl 命令:
|
||||
|
||||
```shell
|
||||
kubectl exec -ti nginx-app-5jyvm -- /bin/sh
|
||||
|
@ -293,7 +299,7 @@ To follow stdout/stderr of a process that is running, see [kubectl logs](/docs/r
|
|||
<!--
|
||||
docker:
|
||||
-->
|
||||
使用 Docker 命令:
|
||||
使用 docker 命令:
|
||||
|
||||
```shell
|
||||
docker logs -f a9e
|
||||
|
@ -320,7 +326,7 @@ kubectl logs -f nginx-app-zibvs
|
|||
There is a slight difference between pods and containers; by default pods do not terminate if their processes exit. Instead the pods restart the process. This is similar to the docker run option `--restart=always` with one major difference. In docker, the output for each invocation of the process is concatenated, but for Kubernetes, each invocation is separate. To see the output from a previous run in Kubernetes, do this:
|
||||
-->
|
||||
现在是时候提一下 Pod 和容器之间的细微差别了;默认情况下如果 Pod 中的进程退出 Pod 也不会终止,
|
||||
相反它将会重启该进程。这类似于 docker run 时的 `--restart=always` 选项,这是主要差别。
|
||||
相反它将会重启该进程。这类似于 `docker run` 时的 `--restart=always` 选项,这是主要差别。
|
||||
在 Docker 中,进程的每个调用的输出都是被连接起来的,但是对于 Kubernetes,每个调用都是分开的。
|
||||
要查看以前在 Kubernetes 中执行的输出,请执行以下操作:
|
||||
|
||||
|
@ -350,7 +356,7 @@ To stop and delete a running process, see [kubectl delete](/docs/reference/gener
|
|||
<!--
|
||||
docker:
|
||||
-->
|
||||
使用 Docker 命令:
|
||||
使用 docker 命令:
|
||||
|
||||
```shell
|
||||
docker ps
|
||||
|
@ -427,12 +433,12 @@ There is no direct analog of `docker login` in kubectl. If you are interested in
|
|||
<!--
|
||||
To get the version of client and server, see [kubectl version](/docs/reference/generated/kubectl/kubectl-commands/#version).
|
||||
-->
|
||||
如何查看客户端和服务端的版本?查看 [kubectl version](/docs/reference/generated/kubectl/kubectl-commands/#version)。
|
||||
如何查看客户端和服务端的版本?查看 [kubectl version](/zh-cn/docs/reference/generated/kubectl/kubectl-commands/#version)。
|
||||
|
||||
<!--
|
||||
docker:
|
||||
-->
|
||||
使用 Docker 命令:
|
||||
使用 docker 命令:
|
||||
|
||||
```shell
|
||||
docker version
|
||||
|
@ -473,7 +479,7 @@ To get miscellaneous information about the environment and configuration, see [k
|
|||
<!--
|
||||
docker:
|
||||
-->
|
||||
使用 Docker 命令:
|
||||
使用 docker 命令:
|
||||
|
||||
```shell
|
||||
docker info
|
||||
|
|
|
@ -22,11 +22,12 @@ verification and functionality test for a node. The test validates whether the
|
|||
node meets the minimum requirements for Kubernetes; a node that passes the test
|
||||
is qualified to join a Kubernetes cluster.
|
||||
-->
|
||||
**节点一致性测试** 是一个容器化的测试框架,提供了针对节点的系统验证和功能测试。
|
||||
**节点一致性测试**是一个容器化的测试框架,提供了针对节点的系统验证和功能测试。
|
||||
测试验证节点是否满足 Kubernetes 的最低要求;通过测试的节点有资格加入 Kubernetes 集群。
|
||||
|
||||
<!--
|
||||
The test validates whether the node meets the minimum requirements for Kubernetes; a node that passes the testis qualified to join a Kubernetes cluster.
|
||||
The test validates whether the node meets the minimum requirements for Kubernetes;
|
||||
a node that passes the testis qualified to join a Kubernetes cluster.
|
||||
-->
|
||||
该测试主要检测节点是否满足 Kubernetes 的最低要求,通过检测的节点有资格加入 Kubernetes 集群。
|
||||
|
||||
|
@ -40,14 +41,15 @@ To run node conformance test, a node must satisfy the same prerequisites as a
|
|||
standard Kubernetes node. At a minimum, the node should have the following
|
||||
daemons installed:
|
||||
-->
|
||||
要运行节点一致性测试,节点必须满足与标准 Kubernetes 节点相同的前提条件。节点至少应安装以下守护程序:
|
||||
要运行节点一致性测试,节点必须满足与标准 Kubernetes 节点相同的前提条件。
|
||||
节点至少应安装以下守护程序:
|
||||
|
||||
<!--
|
||||
* CRI-compatible container runtimes such as Docker, Containerd and CRI-O
|
||||
* Kubelet
|
||||
* CRI-compatible container runtimes such as Docker, Containerd and CRI-O
|
||||
* kubelet
|
||||
-->
|
||||
* 与 CRI 兼容的容器运行时,例如 Docker、Containerd 和 CRI-O
|
||||
* Kubelet
|
||||
* kubelet
|
||||
|
||||
<!--
|
||||
## Running Node Conformance Test
|
||||
|
@ -65,8 +67,8 @@ To run the node conformance test, perform the following steps:
|
|||
Because the test framework starts a local control plane to test the kubelet,
|
||||
use `http://localhost:8080` as the URL of the API server.
|
||||
There are some other kubelet command line parameters you may want to use:
|
||||
* `--cloud-provider`: If you are using `--cloud-provider=gce`, you should
|
||||
remove the flag to run the test.
|
||||
* `--cloud-provider`: If you are using `--cloud-provider=gce`, you should
|
||||
remove the flag to run the test.
|
||||
-->
|
||||
1. 得出 kubelet 的 `--kubeconfig` 的值;例如:`--kubeconfig=/var/lib/kubelet/config.yaml`。
|
||||
由于测试框架启动了本地控制平面来测试 kubelet,因此使用 `http://localhost:8080`
|
||||
|
@ -75,20 +77,21 @@ To run the node conformance test, perform the following steps:
|
|||
* `--cloud-provider`:如果使用 `--cloud-provider=gce`,需要移除这个参数来运行测试。
|
||||
|
||||
<!--
|
||||
2. Run the node conformance test with command:
|
||||
1. Run the node conformance test with command:
|
||||
|
||||
```shell
|
||||
# $CONFIG_DIR is the pod manifest path of your Kubelet.
|
||||
# $LOG_DIR is the test output path.
|
||||
sudo docker run -it --rm --privileged --net=host \
|
||||
-v /:/rootfs -v $CONFIG_DIR:$CONFIG_DIR -v $LOG_DIR:/var/result \
|
||||
registry.k8s.io/node-test:0.2
|
||||
```shell
|
||||
# $CONFIG_DIR is the pod manifest path of your kubelet.
|
||||
# $LOG_DIR is the test output path.
|
||||
sudo docker run -it --rm --privileged --net=host \
|
||||
-v /:/rootfs -v $CONFIG_DIR:$CONFIG_DIR -v $LOG_DIR:/var/result \
|
||||
registry.k8s.io/node-test:0.2
|
||||
```
|
||||
```
|
||||
-->
|
||||
2. 使用以下命令运行节点一致性测试:
|
||||
|
||||
```shell
|
||||
# $CONFIG_DIR 是你 Kubelet 的 pod manifest 路径。
|
||||
# $CONFIG_DIR 是你 kubelet 的 Pod manifest 路径。
|
||||
# $LOG_DIR 是测试的输出路径。
|
||||
sudo docker run -it --rm --privileged --net=host \
|
||||
-v /:/rootfs -v $CONFIG_DIR:$CONFIG_DIR -v $LOG_DIR:/var/result \
|
||||
|
@ -107,17 +110,17 @@ architectures:
|
|||
Kubernetes 也为其他硬件体系结构的系统提供了节点一致性测试的 Docker 镜像:
|
||||
|
||||
<!--
|
||||
Arch | Image |
|
||||
--------|:-----------------:|
|
||||
amd64 | node-test-amd64 |
|
||||
arm | node-test-arm |
|
||||
arm64 | node-test-arm64 |
|
||||
| Arch | Image |
|
||||
|--------|:-----------------:|
|
||||
| amd64 | node-test-amd64 |
|
||||
| arm | node-test-arm |
|
||||
| arm64 | node-test-arm64 |
|
||||
-->
|
||||
架构 | 镜像 |
|
||||
--------|:-----------------:|
|
||||
amd64 | node-test-amd64 |
|
||||
arm | node-test-arm |
|
||||
arm64 | node-test-arm64 |
|
||||
| 架构 | 镜像 |
|
||||
|--------|:-----------------:|
|
||||
| amd64 | node-test-amd64 |
|
||||
| arm | node-test-arm |
|
||||
| arm64 | node-test-arm64 |
|
||||
|
||||
<!--
|
||||
## Running Selected Test
|
||||
|
@ -158,14 +161,13 @@ sudo docker run -it --rm --privileged --net=host \
|
|||
registry.k8s.io/node-test:0.2
|
||||
```
|
||||
|
||||
|
||||
<!--
|
||||
Node conformance test is a containerized version of [node e2e test](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-node/e2e-node-tests.md).
|
||||
-->
|
||||
节点一致性测试是[节点端到端测试](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-node/e2e-node-tests.md)的容器化版本。
|
||||
<!--
|
||||
Node conformance test is a containerized version of
|
||||
[node e2e test](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-node/e2e-node-tests.md).
|
||||
By default, it runs all conformance tests.
|
||||
-->
|
||||
节点一致性测试是
|
||||
[节点端到端测试](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-node/e2e-node-tests.md)的容器化版本。
|
||||
默认情况下,它会运行所有一致性测试。
|
||||
|
||||
<!--
|
||||
|
@ -173,7 +175,8 @@ Theoretically, you can run any node e2e test if you configure the container and
|
|||
mount required volumes properly. But **it is strongly recommended to only run conformance
|
||||
test**, because it requires much more complex configuration to run non-conformance test.
|
||||
-->
|
||||
理论上,只要合理地配置容器和挂载所需的卷,就可以运行任何的节点端到端测试用例。但是这里**强烈建议只运行一致性测试**,因为运行非一致性测试需要很多复杂的配置。
|
||||
理论上,只要合理地配置容器和挂载所需的卷,就可以运行任何的节点端到端测试用例。
|
||||
但是这里**强烈建议只运行一致性测试**,因为运行非一致性测试需要很多复杂的配置。
|
||||
|
||||
<!--
|
||||
## Caveats
|
||||
|
@ -187,6 +190,5 @@ test**, because it requires much more complex configuration to run non-conforman
|
|||
* The test leaves dead containers on the node. These containers are created
|
||||
during the functionality test.
|
||||
-->
|
||||
|
||||
* 测试会在节点上遗留一些 Docker 镜像,包括节点一致性测试本身的镜像和功能测试相关的镜像。
|
||||
* 测试会在节点上遗留一些死的容器。这些容器是在功能测试的过程中创建的。
|
||||
|
|
Loading…
Reference in New Issue