Skip to content

Commit 7f72658

Browse files
committed
[zh] Sync /access-application-cluster/access-cluster.md
1 parent fb8f9b8 commit 7f72658

File tree

1 file changed

+75
-70
lines changed

1 file changed

+75
-70
lines changed

content/zh-cn/docs/tasks/access-application-cluster/access-cluster.md

Lines changed: 75 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ title: 访问集群
33
weight: 20
44
content_type: concept
55
---
6-
76
<!--
87
title: Accessing Clusters
98
weight: 20
@@ -28,7 +27,7 @@ When accessing the Kubernetes API for the first time, we suggest using the
2827
Kubernetes CLI, `kubectl`.
2928
3029
To access a cluster, you need to know the location of the cluster and have credentials
31-
to access it. Typically, this is automatically set-up when you work through
30+
to access it. Typically, this is automatically set-up when you work through
3231
a [Getting started guide](/docs/setup/),
3332
or someone else set up the cluster and provided you with credentials and a location.
3433
@@ -38,9 +37,9 @@ Check the location and credentials that kubectl knows about with this command:
3837

3938
当你第一次访问 Kubernetes API 的时候,我们建议你使用 Kubernetes CLI 工具 `kubectl`
4039

41-
访问集群时,你需要知道集群的地址并且拥有访问的凭证。通常,这些在你通过
42-
[启动安装](/zh-cn/docs/setup/)安装集群时都是自动安装好的,或者其他人安装时
43-
也应该提供了凭证和集群地址
40+
访问集群时,你需要知道集群的地址并且拥有访问的凭证。通常,
41+
这些在你通过[启动安装](/zh-cn/docs/setup/)安装集群时都是自动安装好的,
42+
或者其他人安装时也应该提供了凭证和集群地址
4443

4544
通过以下命令检查 kubectl 是否知道集群地址及凭证:
4645

@@ -63,38 +62,38 @@ Kubectl handles locating and authenticating to the apiserver.
6362
If you want to directly access the REST API with an http client like
6463
curl or wget, or a browser, there are several ways to locate and authenticate:
6564
66-
- Run kubectl in proxy mode.
67-
- Recommended approach.
68-
- Uses stored apiserver location.
69-
- Verifies identity of apiserver using self-signed cert. No MITM possible.
70-
- Authenticates to apiserver.
71-
- In future, may do intelligent client-side load-balancing and failover.
72-
- Provide the location and credentials directly to the http client.
73-
- Alternate approach.
74-
- Works with some types of client code that are confused by using a proxy.
75-
- Need to import a root cert into your browser to protect against MITM.
65+
- Run kubectl in proxy mode.
66+
- Recommended approach.
67+
- Uses stored apiserver location.
68+
- Verifies identity of apiserver using self-signed cert. No MITM possible.
69+
- Authenticates to apiserver.
70+
- In future, may do intelligent client-side load-balancing and failover.
71+
- Provide the location and credentials directly to the http client.
72+
- Alternate approach.
73+
- Works with some types of client code that are confused by using a proxy.
74+
- Need to import a root cert into your browser to protect against MITM.
7675
-->
7776
## 直接访问 REST API {#directly-accessing-the-rest-api}
7877

7978
Kubectl 处理 apiserver 的定位和身份验证。
80-
如果要使用 curl 或 wget 等 http 客户端或浏览器直接访问 REST API,可以通过
81-
多种方式查找和验证
79+
如果要使用 curl 或 wget 等 http 客户端或浏览器直接访问 REST API,
80+
可以通过多种方式查找和验证
8281

8382
- 以代理模式运行 kubectl。
8483
- 推荐此方式。
8584
- 使用已存储的 apiserver 地址。
8685
- 使用自签名的证书来验证 apiserver 的身份。杜绝 MITM 攻击。
8786
- 对 apiserver 进行身份验证。
8887
- 未来可能会实现智能化的客户端负载均衡和故障恢复。
89-
- 直接向 http 客户端提供位置和凭据
88+
- 直接向 http 客户端提供位置和凭证
9089
- 可选的方案。
9190
- 适用于代理可能引起混淆的某些客户端类型。
9291
- 需要引入根证书到你的浏览器以防止 MITM 攻击。
9392

9493
<!--
9594
### Using kubectl proxy
9695
97-
The following command runs kubectl in a mode where it acts as a reverse proxy. It handles
96+
The following command runs kubectl in a mode where it acts as a reverse proxy. It handles
9897
locating the apiserver and authenticating.
9998
Run it like this:
10099
-->
@@ -149,9 +148,7 @@ The output is similar to this:
149148
Use `kubectl apply` and `kubectl describe secret...` to create a token for the default service account with grep/cut:
150149
151150
First, create the Secret, requesting a token for the default ServiceAccount:
152-
153151
-->
154-
155152
### 不使用 kubectl proxy {#without-kubectl-proxy}
156153

157154
使用 `kubectl apply``kubectl describe secret ...` 及 grep 和剪切操作来为 default 服务帐户创建令牌,如下所示:
@@ -245,16 +242,16 @@ The output is similar to this:
245242
```
246243

247244
<!--
248-
The above examples use the `--insecure` flag. This leaves it subject to MITM
249-
attacks. When kubectl accesses the cluster it uses a stored root certificate
250-
and client certificates to access the server. (These are installed in the
251-
`~/.kube` directory). Since cluster certificates are typically self-signed, it
245+
The above examples use the `--insecure` flag. This leaves it subject to MITM
246+
attacks. When kubectl accesses the cluster it uses a stored root certificate
247+
and client certificates to access the server. (These are installed in the
248+
`~/.kube` directory). Since cluster certificates are typically self-signed, it
252249
may take special configuration to get your http client to use root
253250
certificate.
254251
255252
On some clusters, the apiserver does not require authentication; it may serve
256-
on localhost, or be protected by a firewall. There is not a standard
257-
for this. [Controlling Access to the API](/docs/concepts/security/controlling-access)
253+
on localhost, or be protected by a firewall. There is not a standard
254+
for this. [Controlling Access to the API](/docs/concepts/security/controlling-access)
258255
describes how a cluster admin can configure this.
259256
-->
260257
上面的例子使用了 `--insecure` 参数,这使得它很容易受到 MITM 攻击。
@@ -275,11 +272,18 @@ client libraries.
275272
276273
### Go client
277274
278-
* To get the library, run the following command: `go get k8s.io/client-go@kubernetes-<kubernetes-version-number>`, see [INSTALL.md](https://github.com/kubernetes/client-go/blob/master/INSTALL.md#for-the-casual-user) for detailed installation instructions. See [https://github.com/kubernetes/client-go](https://github.com/kubernetes/client-go#compatibility-matrix) to see which versions are supported.
279-
* Write an application atop of the client-go clients. Note that client-go defines its own API objects, so if needed, please import API definitions from client-go rather than from the main repository, e.g., `import "k8s.io/client-go/kubernetes"` is correct.
275+
* To get the library, run the following command: `go get k8s.io/client-go@kubernetes-<kubernetes-version-number>`,
276+
see [INSTALL.md](https://github.com/kubernetes/client-go/blob/master/INSTALL.md#for-the-casual-user)
277+
for detailed installation instructions. See
278+
[https://github.com/kubernetes/client-go](https://github.com/kubernetes/client-go#compatibility-matrix)
279+
to see which versions are supported.
280+
* Write an application atop of the client-go clients. Note that client-go defines its own API objects,
281+
so if needed, please import API definitions from client-go rather than from the main repository,
282+
e.g., `import "k8s.io/client-go/kubernetes"` is correct.
280283
281284
The Go client can use the same [kubeconfig file](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
282-
as the kubectl CLI does to locate and authenticate to the apiserver. See this [example](https://git.k8s.io/client-go/examples/out-of-cluster-client-configuration/main.go).
285+
as the kubectl CLI does to locate and authenticate to the apiserver. See this
286+
[example](https://git.k8s.io/client-go/examples/out-of-cluster-client-configuration/main.go).
283287
284288
If the application is deployed as a Pod in the cluster, please refer to the [next section](#accessing-the-api-from-a-pod).
285289
-->
@@ -307,10 +311,13 @@ Go 客户端可以像 kubectl CLI 一样使用相同的
307311
<!--
308312
### Python client
309313
310-
To use [Python client](https://github.com/kubernetes-client/python), run the following command: `pip install kubernetes`. See [Python Client Library page](https://github.com/kubernetes-client/python) for more installation options.
314+
To use [Python client](https://github.com/kubernetes-client/python), run the following command:
315+
`pip install kubernetes`. See [Python Client Library page](https://github.com/kubernetes-client/python)
316+
for more installation options.
311317
312318
The Python client can use the same [kubeconfig file](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
313-
as the kubectl CLI does to locate and authenticate to the apiserver. See this [example](https://github.com/kubernetes-client/python/tree/master/examples).
319+
as the kubectl CLI does to locate and authenticate to the apiserver. See this
320+
[example](https://github.com/kubernetes-client/python/tree/master/examples).
314321
315322
### Other languages
316323
@@ -359,36 +366,34 @@ The previous section describes how to connect to the Kubernetes API server.
359366
For information about connecting to other services running on a Kubernetes cluster, see
360367
[Access Cluster Services](/docs/tasks/access-application-cluster/access-cluster-services/).
361368
-->
362-
363369
## 访问集群上运行的服务 {#accessing-services-running-on-the-cluster}
364370

365371
上一节介绍了如何连接到 Kubernetes API 服务器。
366-
有关连接到 Kubernetes 集群上运行的其他服务的信息,请参阅
367-
[访问集群服务](/zh-cn/docs/tasks/access-application-cluster/access-cluster-services/)
372+
有关连接到 Kubernetes 集群上运行的其他服务的信息,
373+
请参阅[访问集群服务](/zh-cn/docs/tasks/access-application-cluster/access-cluster-services/)
368374

369375
<!--
370376
## Requesting redirects
371377
372-
The redirect capabilities have been deprecated and removed. Please use a proxy (see below) instead.
378+
The redirect capabilities have been deprecated and removed. Please use a proxy (see below) instead.
373379
-->
374380
## 请求重定向 {#requesting-redirects}
375381

376382
重定向功能已弃用并被删除。请改用代理(见下文)。
377383

378384
<!--
379-
## So Many Proxies
385+
## So many proxies
380386
381387
There are several different proxies you may encounter when using Kubernetes:
382388
383-
1. The [kubectl proxy](#directly-accessing-the-rest-api):
384-
385-
- runs on a user's desktop or in a pod
386-
- proxies from a localhost address to the Kubernetes apiserver
387-
- client to proxy uses HTTP
388-
- proxy to apiserver uses HTTPS
389-
- locates apiserver
390-
- adds authentication headers
389+
1. The [kubectl proxy](#directly-accessing-the-rest-api):
391390
391+
- runs on a user's desktop or in a pod
392+
- proxies from a localhost address to the Kubernetes apiserver
393+
- client to proxy uses HTTP
394+
- proxy to apiserver uses HTTPS
395+
- locates apiserver
396+
- adds authentication headers
392397
-->
393398
## 多种代理 {#so-many-proxies}
394399

@@ -404,15 +409,15 @@ There are several different proxies you may encounter when using Kubernetes:
404409
- 添加身份验证头部
405410

406411
<!--
407-
1. The [apiserver proxy](/docs/tasks/access-application-cluster/access-cluster-services/#discovering-builtin-services):
408-
409-
- is a bastion built into the apiserver
410-
- connects a user outside of the cluster to cluster IPs which otherwise might not be reachable
411-
- runs in the apiserver processes
412-
- client to proxy uses HTTPS (or http if apiserver so configured)
413-
- proxy to target may use HTTP or HTTPS as chosen by proxy using available information
414-
- can be used to reach a Node, Pod, or Service
415-
- does load balancing when used to reach a Service
412+
1. The [apiserver proxy](/docs/tasks/access-application-cluster/access-cluster-services/#discovering-builtin-services):
413+
414+
- is a bastion built into the apiserver
415+
- connects a user outside of the cluster to cluster IPs which otherwise might not be reachable
416+
- runs in the apiserver processes
417+
- client to proxy uses HTTPS (or http if apiserver so configured)
418+
- proxy to target may use HTTP or HTTPS as chosen by proxy using available information
419+
- can be used to reach a Node, Pod, or Service
420+
- does load balancing when used to reach a Service
416421
-->
417422
2. [apiserver 代理](/zh-cn/docs/tasks/access-application-cluster/access-cluster-services/#discovering-builtin-services)
418423

@@ -425,13 +430,13 @@ There are several different proxies you may encounter when using Kubernetes:
425430
- 在访问服务时进行负载平衡
426431

427432
<!--
428-
1. The [kube proxy](/docs/concepts/services-networking/service/#ips-and-vips):
433+
1. The [kube proxy](/docs/concepts/services-networking/service/#ips-and-vips):
429434
430-
- runs on each node
431-
- proxies UDP and TCP
432-
- does not understand HTTP
433-
- provides load balancing
434-
- is only used to reach services
435+
- runs on each node
436+
- proxies UDP and TCP
437+
- does not understand HTTP
438+
- provides load balancing
439+
- is only used to reach services
435440
-->
436441
3. [kube proxy](/zh-cn/docs/concepts/services-networking/service/#ips-and-vips)
437442

@@ -442,11 +447,11 @@ There are several different proxies you may encounter when using Kubernetes:
442447
- 只能用来访问服务
443448

444449
<!--
445-
1. A Proxy/Load-balancer in front of apiserver(s):
450+
1. A Proxy/Load-balancer in front of apiserver(s):
446451
447-
- existence and implementation varies from cluster to cluster (e.g. nginx)
448-
- sits between all clients and one or more apiservers
449-
- acts as load balancer if there are several apiservers.
452+
- existence and implementation varies from cluster to cluster (e.g. nginx)
453+
- sits between all clients and one or more apiservers
454+
- acts as load balancer if there are several apiservers.
450455
-->
451456
4. 位于 apiserver 之前的 Proxy/Load-balancer:
452457

@@ -455,14 +460,14 @@ There are several different proxies you may encounter when using Kubernetes:
455460
- 如果有多个 apiserver,则充当负载均衡器
456461

457462
<!--
458-
1. Cloud Load Balancers on external services:
463+
1. Cloud Load Balancers on external services:
459464
460-
- are provided by some cloud providers (e.g. AWS ELB, Google Cloud Load Balancer)
461-
- are created automatically when the Kubernetes service has type `LoadBalancer`
462-
- use UDP/TCP only
463-
- implementation varies by cloud provider.
465+
- are provided by some cloud providers (e.g. AWS ELB, Google Cloud Load Balancer)
466+
- are created automatically when the Kubernetes service has type `LoadBalancer`
467+
- use UDP/TCP only
468+
- implementation varies by cloud provider.
464469
465-
Kubernetes users will typically not need to worry about anything other than the first two types. The cluster admin
470+
Kubernetes users will typically not need to worry about anything other than the first two types. The cluster admin
466471
will typically ensure that the latter types are set up correctly.
467472
-->
468473
5. 外部服务上的云负载均衡器:

0 commit comments

Comments
 (0)