You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/zh/docs/reference/kubectl/docker-cli-to-kubectl.md
+23-21Lines changed: 23 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,18 @@
1
1
---
2
2
title: 适用于 Docker 用户的 kubectl
3
3
content_type: concept
4
-
reviewers:
5
-
- brendandburns
6
-
- thockin
7
4
---
8
5
<!--
9
-
---
10
6
title: kubectl for Docker Users
11
7
content_type: concept
12
8
reviewers:
13
9
- brendandburns
14
10
- thockin
15
-
---
16
11
-->
17
12
18
13
<!-- overview -->
19
14
<!--
20
-
You can use the Kubernetes command line tool `kubectl` to interact with the API Server. Using kubectl is straightforward if you are familiar with the Docker command line tool. However, there are a few differences between the docker commands and the kubectl commands. The following sections show a Docker sub-command and describe the equivalent `kubectl` command.
15
+
You can use the Kubernetes command line tool `kubectl` to interact with the API Server. Using kubectl is straightforward if you are familiar with the Docker command line tool. However, there are a few differences between the Docker commands and the kubectl commands. The following sections show a Docker sub-command and describe the equivalent `kubectl` command.
21
16
-->
22
17
你可以使用 Kubernetes 命令行工具 `kubectl` 与 API 服务器进行交互。如果你熟悉 Docker 命令行工具,
@@ -30,8 +25,12 @@ You can use the Kubernetes command line tool `kubectl` to interact with the API
30
25
<!--
31
26
To run an nginx Deployment and expose the Deployment, see [kubectl create deployment](/docs/reference/generated/kubectl/kubectl-commands#-em-deployment-em-).
@@ -48,7 +47,10 @@ CONTAINER ID IMAGE COMMAND CREATED
48
47
55c103fa1296 nginx "nginx -g 'daemon of…" 9 seconds ago Up 9 seconds 0.0.0.0:80->80/tcp nginx-app
49
48
```
50
49
50
+
<!--
51
51
kubectl:
52
+
-->
53
+
使用 kubectl 命令:
52
54
53
55
<!--
54
56
```shell
@@ -97,7 +99,7 @@ service "nginx-http" exposed
97
99
By using kubectl, you can create a [Deployment](/docs/concepts/workloads/controllers/deployment/) to ensure that N pods are running nginx, where N is the number of replicas stated in the spec and defaults to 1. You can also create a [service](/docs/concepts/services-networking/service/) with a selector that matches the pod labels. For more information, see [Use a Service to Access an Application in a Cluster](/docs/tasks/access-application-cluster/service-access-application-cluster).
Unlike `docker run ...`, if you specify `--attach`, then you attach `stdin`, `stdout` and `stderr`. You cannot control which streams are attached (`docker -a ...`).
116
118
To detach from the container, you can type the escape sequence Ctrl+P followed by Ctrl+Q.
117
119
-->
118
-
与 `docker run ...` 不同的是,如果指定了 `--attach`,我们将连接到 `stdin`,`stdout` 和 `stderr`,
120
+
与 `docker run ...` 不同的是,如果指定了 `--attach`,我们将连接到 `stdin`,`stdout` 和 `stderr`,
119
121
而不能控制具体连接到哪个输出流(`docker -a ...`)。要从容器中退出,可以输入 Ctrl + P,然后按 Ctrl + Q。
120
122
121
123
<!--
122
124
Because the kubectl run command starts a Deployment for the container, the Deployment restarts if you terminate the attached process by using Ctrl+C, unlike `docker run -it`.
123
125
To destroy the Deployment and its pods you need to run `kubectl delete deployment <name>`.
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:
319
321
-->
320
322
现在是时候提一下 Pod 和容器之间的细微差别了;默认情况下如果 Pod 中的进程退出 Pod 也不会终止,
321
-
相反它将会重启该进程。这类似于 docker run 时的 `--restart=always` 选项,这是主要差别。
@@ -403,7 +405,7 @@ kubectl get po -l app=nginx-app
403
405
404
406
{{< note >}}
405
407
<!--
406
-
When you use kubectl, you don't delete the pod directly.You have to first delete the Deployment that owns the pod. If you delete the pod directly, the Deployment recreates the pod.
408
+
When you use kubectl, you don't delete the pod directly.You have to first delete the Deployment that owns the pod. If you delete the pod directly, the Deployment recreates the pod.
407
409
-->
408
410
请注意,我们不直接删除 Pod。使用 kubectl 命令,我们要删除拥有该 Pod 的 Deployment。
409
411
如果我们直接删除 Pod,Deployment 将会重新创建该 Pod。
@@ -501,10 +503,10 @@ kubectl:
501
503
kubectl cluster-info
502
504
```
503
505
```
504
-
Kubernetes master is running at https://108.59.85.141
505
-
KubeDNS is running at https://108.59.85.141/api/v1/namespaces/kube-system/services/kube-dns/proxy
506
-
kubernetes-dashboard is running at https://108.59.85.141/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy
507
-
Grafana is running at https://108.59.85.141/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
508
-
Heapster is running at https://108.59.85.141/api/v1/namespaces/kube-system/services/monitoring-heapster/proxy
509
-
InfluxDB is running at https://108.59.85.141/api/v1/namespaces/kube-system/services/monitoring-influxdb/proxy
506
+
Kubernetes master is running at https://203.0.113.141
507
+
KubeDNS is running at https://203.0.113.141/api/v1/namespaces/kube-system/services/kube-dns/proxy
508
+
kubernetes-dashboard is running at https://203.0.113.141/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy
509
+
Grafana is running at https://203.0.113.141/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
510
+
Heapster is running at https://203.0.113.141/api/v1/namespaces/kube-system/services/monitoring-heapster/proxy
511
+
InfluxDB is running at https://203.0.113.141/api/v1/namespaces/kube-system/services/monitoring-influxdb/proxy
0 commit comments