[zh] Sync English site changes (9)

This commit is contained in:
Qiming Teng
2020-11-20 16:42:37 +08:00
parent 1e38b53fc8
commit 51949a9403
11 changed files with 270 additions and 237 deletions
@@ -203,7 +203,7 @@ users:
<!--
The `fake-ca-file`, `fake-cert-file` and `fake-key-file` above are the placeholders
for the pathnames of the certificate files. You need change these to the actual pathnames
for the pathnames of the certificate files. You need to change these to the actual pathnames
of certificate files in your environment.
Sometimes you may want to use Base64-encoded data embedded here instead of separate
@@ -228,10 +228,10 @@ so that you can change the configuration more easily.
<!--
## Interact with the frontend Service
Once youve created a Service of type LoadBalancer, you can use this
Once you've created a Service of type LoadBalancer, you can use this
command to find the external IP:
-->
### 与前端 Service 交互
### 与前端 Service 交互 {#interact-with-the-frontend-service}
一旦你创建了 LoadBalancer 类型的 Service,你可以使用这条命令查看外部 IP:
@@ -61,9 +61,9 @@ This page shows you how to set up a simple Ingress which routes requests to Serv
1. 为了启用 NGINIX Ingress 控制器,可以运行下面的命令:
```shell
minikube addons enable ingress
```
```shell
minikube addons enable ingress
```
<!--
1. Verify that the NGINX Ingress controller is running
@@ -75,11 +75,13 @@ This page shows you how to set up a simple Ingress which routes requests to Serv
```
<!-- This can take up to a minute. -->
{{< note >}}这一操作可供需要近一分钟时间。{{< /note >}}
{{< note >}}
这一操作可能需要近一分钟时间。
{{< /note >}}
输出:
```shell
```
NAME READY STATUS RESTARTS AGE
default-http-backend-59868b7dd6-xb8tq 1/1 Running 0 1m
kube-addon-manager-minikube 1/1 Running 0 3m
@@ -197,7 +199,7 @@ The following file is an Ingress resource that sends traffic to your Service via
1. 根据下面的 YAML 创建文件 `example-ingress.yaml`
{{< codenew file="service/networking/example-ingress.yaml" >}}
{{< codenew file="service/networking/example-ingress.yaml" >}}
<!--
1. Create the Ingress resource by running the following command:
@@ -211,9 +213,10 @@ The following file is an Ingress resource that sends traffic to your Service via
<!-- Output: -->
输出:
```shell
```
ingress.networking.k8s.io/example-ingress created
```
<!--
1. Verify the IP address is set:
-->
@@ -224,9 +227,11 @@ The following file is an Ingress resource that sends traffic to your Service via
```
<!-- This can take a couple of minutes. -->
{{< note >}}此操作可能需要几分钟时间。{{< /note >}}
{{< note >}}
此操作可能需要几分钟时间。
{{< /note >}}
```shell
```
NAME CLASS HOSTS ADDRESS PORTS AGE
example-ingress <none> hello-world.info 172.17.0.15 80 38s
```
@@ -262,7 +267,7 @@ The following file is an Ingress resource that sends traffic to your Service via
<!-- Output: -->
输出:
```shell
```
Hello, world!
Version: 1.0.0
Hostname: web-55b8c6998d-8k564
@@ -290,7 +295,7 @@ The following file is an Ingress resource that sends traffic to your Service via
<!-- Output: -->
输出:
```shell
```
deployment.apps/web2 created
```
@@ -306,7 +311,7 @@ The following file is an Ingress resource that sends traffic to your Service via
<!-- Output: -->
输出:
```shell
```
service/web2 exposed
```
@@ -321,13 +326,13 @@ The following file is an Ingress resource that sends traffic to your Service via
```yaml
- path: /v2
pathType: Prefix
backend:
service:
name: web2
port:
number: 8080
- path: /v2
pathType: Prefix
backend:
service:
name: web2
port:
number: 8080
```
<!--
@@ -342,7 +347,7 @@ The following file is an Ingress resource that sends traffic to your Service via
<!-- Output: -->
输出:
```shell
```
ingress.networking/example-ingress configured
```
@@ -5,27 +5,22 @@ weight: 40
---
<!--
---
title: Use Port Forwarding to Access Applications in a Cluster
content_type: task
weight: 40
---
-->
<!-- overview -->
<!--
This page shows how to use `kubectl port-forward` to connect to a Redis
server running in a Kubernetes cluster. This type of connection can be useful
for database debugging.
-->
本文展示如何使用 `kubectl port-forward` 连接到在 Kubernetes 集群中运行的 Redis 服务。这种类型的连接对数据库调试很有用。
本文展示如何使用 `kubectl port-forward` 连接到在 Kubernetes 集群中
运行的 Redis 服务。这种类型的连接对数据库调试很有用。
## {{% heading "prerequisites" %}}
* {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
<!--
@@ -33,9 +28,6 @@ for database debugging.
-->
* 安装 [redis-cli](http://redis.io/topics/rediscli)。
<!-- steps -->
<!--
@@ -47,172 +39,206 @@ for database debugging.
1. 创建一个 Redis deployment
kubectl apply -f https://k8s.io/examples/application/guestbook/redis-master-deployment.yaml
```shell
kubectl apply -f https://k8s.io/examples/application/guestbook/redis-master-deployment.yaml
```
<!--
The output of a successful command verifies that the deployment was created:
-->
查看输出是否成功,以验证是否成功创建 deployment
<!--
The output of a successful command verifies that the deployment was created:
-->
查看输出是否成功,以验证是否成功创建 deployment
deployment.apps/redis-master created
<!--
View the pod status to check that it is ready:
-->
查看 pod 状态,检查其是否准备就绪:
```
deployment.apps/redis-master created
```
kubectl get pods
<!--
The output displays the pod created:
-->
输出显示创建的 pod
<!--
View the pod status to check that it is ready:
-->
查看 pod 状态,检查其是否准备就绪:
NAME READY STATUS RESTARTS AGE
redis-master-765d459796-258hz 1/1 Running 0 50s
```shell
kubectl get pods
```
<!--
View the deployment status:
-->
查看 deployment 状态
<!--
The output displays the pod created:
-->
输出显示创建的 pod
kubectl get deployment
```
NAME READY STATUS RESTARTS AGE
redis-master-765d459796-258hz 1/1 Running 0 50s
```
<!--
The output displays that the deployment was created:
-->
输出显示创建的 deployment
<!--
View the deployment status:
-->
查看 deployment 状态
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
redis-master 1 1 1 1 55s
```shell
kubectl get deployment
```
<!--
View the replicaset status using:
-->
查看 replicaset 状态
<!--
The output displays that the deployment was created:
-->
输出显示创建的 deployment
kubectl get rs
```
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
redis-master 1 1 1 1 55s
```
<!--
The output displays that the replicaset was created:
-->
输出显示创建的 replicaset
<!--
View the replicaset status using:
-->
查看 replicaset 状态
NAME DESIRED CURRENT READY AGE
redis-master-765d459796 1 1 1 1m
```shell
kubectl get rs
```
<!--
The output displays that the replicaset was created:
-->
输出显示创建的 replicaset
```
NAME DESIRED CURRENT READY AGE
redis-master-765d459796 1 1 1 1m
```
<!--
2. Create a Redis service:
-->
2. 创建一个 Redis 服务:
kubectl apply -f https://k8s.io/examples/application/guestbook/redis-master-service.yaml
```shell
kubectl apply -f https://k8s.io/examples/application/guestbook/redis-master-service.yaml
```
<!--
The output of a successful command verifies that the service was created:
-->
查看输出是否成功,以验证是否成功创建 service:
<!--
The output of a successful command verifies that the service was created:
-->
查看输出是否成功,以验证是否成功创建 service:
service/redis-master created
```
service/redis-master created
```
<!--
Check the service created:
-->
检查 service 是否创建:
<!--
Check the service created:
-->
检查 service 是否创建:
kubectl get svc | grep redis
```shell
kubectl get svc | grep redis
```
<!--
The output displays the service created:
-->
输出显示创建的 service:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
redis-master ClusterIP 10.0.0.213 <none> 6379/TCP 27s
<!--
The output displays the service created:
-->
输出显示创建的 service:
```
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
redis-master ClusterIP 10.0.0.213 <none> 6379/TCP 27s
```
<!--
3. Verify that the Redis server is running in the pod and listening on port 6379:
-->
3. 验证 Redis 服务是否运行在 pod 中并且监听 6379 端口:
```shell
kubectl get pods redis-master-765d459796-258hz \
--template='{{(index (index .spec.containers 0).ports 0).containerPort}}{{"\n"}}'
```
<!--
The output displays the port:
-->
输出应该显示端口:
kubectl get pods redis-master-765d459796-258hz --template='{{(index (index .spec.containers 0).ports 0).containerPort}}{{"\n"}}'
<!--
The output displays the port:
-->
输出应该显示端口:
6379
```
6379
```
<!--
## Forward a local port to a port on the pod
1. `kubectl port-forward` allows using resource name, such as a pod name, to select a matching pod to port forward to since Kubernetes v1.10.
1. `kubectl port-forward` allows using resource name, such as a pod name, to select a matching pod to port forward to since Kubernetes v1.10.
-->
## 转发一个本地端口到 pod 端口
1. 从 Kubernetes v1.10 开始,`kubectl port-forward` 允许使用资源名称(例如 pod 名称)来选择匹配的 pod 来进行端口转发。
1. 从 Kubernetes v1.10 开始,`kubectl port-forward` 允许使用资源名称
(例如 pod 名称)来选择匹配的 pod 来进行端口转发。
kubectl port-forward redis-master-765d459796-258hz 7000:6379
```shell
kubectl port-forward redis-master-765d459796-258hz 7000:6379
```
<!--
which is the same as
-->
这相当于
```shell
kubectl port-forward pods/redis-master-765d459796-258hz 7000:6379
```
<!-- or -->
或者
```shell
kubectl port-forward deployment/redis-master 7000:6379
```
<!-- or -->
或者
```shell
kubectl port-forward rs/redis-master 7000:6379
```
<!-- or -->
或者
```
kubectl port-forward svc/redis-master 7000:redis
```
<!--
Any of the above commands works. The output is similar to this:
-->
以上所有命令都应该有效。输出应该类似于:
```
I0710 14:43:38.274550 3655 portforward.go:225] Forwarding from 127.0.0.1:7000 -> 6379
I0710 14:43:38.274797 3655 portforward.go:225] Forwarding from [::1]:7000 -> 6379
```
<!--
which is the same as
-->
这相当于
kubectl port-forward pods/redis-master-765d459796-258hz 7000:6379
<!--
or
-->
或者
kubectl port-forward deployment/redis-master 7000:6379
<!--
or
-->
或者
kubectl port-forward rs/redis-master 7000:6379
<!--
or
-->
或者
kubectl port-forward svc/redis-master 7000:6379
<!--
Any of the above commands works. The output is similar to this:
-->
以上所有命令都应该有效。输出应该类似于:
I0710 14:43:38.274550 3655 portforward.go:225] Forwarding from 127.0.0.1:7000 -> 6379
I0710 14:43:38.274797 3655 portforward.go:225] Forwarding from [::1]:7000 -> 6379
<!--
2. Start the Redis command line interface:
2. Start the Redis command line interface:
-->
2. 启动 Redis 命令行接口:
redis-cli -p 7000
```shell
redis-cli -p 7000
```
<!--
3. At the Redis command line prompt, enter the `ping` command:
-->
3. 在 Redis 命令行提示符下,输入 `ping` 命令:
127.0.0.1:7000>ping
<!--
A successful ping request returns PONG.
-->
成功的 ping 请求应该返回 PONG。
```
127.0.0.1:7000>ping
```
<!--
A successful ping request returns PONG.
-->
成功的 ping 请求应该返回 PONG。
<!-- discussion -->
@@ -223,9 +249,10 @@ Connections made to local port 7000 are forwarded to port 6379 of the pod that
is running the Redis server. With this connection in place you can use your
local workstation to debug the database that is running in the pod.
-->
## 讨论
## 讨论 {#discussion}
与本地 7000 端口建立的连接将转发到运行 Redis 服务器的 pod 的 6379 端口。通过此连接,您可以使用本地工作站来调试在 pod 中运行的数据库。
与本地 7000 端口建立的连接将转发到运行 Redis 服务器的 pod 的 6379 端口。
通过此连接,您可以使用本地工作站来调试在 pod 中运行的数据库。
<!--
Due to known limitations, port forward today only works for TCP protocol.
@@ -234,19 +261,14 @@ The support to UDP protocol is being tracked in
-->
{{< warning >}}
由于已知的限制,目前的端口转发仅适用于 TCP 协议。
在 [issue 47862](https://github.com/kubernetes/kubernetes/issues/47862) 中正在跟踪对 UDP 协议的支持。
在 [issue 47862](https://github.com/kubernetes/kubernetes/issues/47862)
中正在跟踪对 UDP 协议的支持。
{{< /warning >}}
## {{% heading "whatsnext" %}}
<!--
Learn more about [kubectl port-forward](/docs/reference/generated/kubectl/kubectl-commands/#port-forward).
-->
学习更多关于 [kubectl port-forward](/docs/reference/generated/kubectl/kubectl-commands/#port-forward)。
进一步了解 [kubectl port-forward](/docs/reference/generated/kubectl/kubectl-commands/#port-forward)。