Skip to content

Commit 4305e5a

Browse files
committed
[zh-cn] sync access-cluster-api.md
1 parent eda1e65 commit 4305e5a

File tree

1 file changed

+35
-21
lines changed

1 file changed

+35
-21
lines changed

content/zh-cn/docs/tasks/administer-cluster/access-cluster-api.md

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
---
22
title: 使用 Kubernetes API 访问集群
33
content_type: task
4+
weight: 60
45
---
56
<!--
67
title: Access Clusters Using the Kubernetes API
78
content_type: task
9+
weight: 60
810
-->
911

1012
<!-- overview -->
@@ -21,11 +23,11 @@ This page shows how to access clusters using the Kubernetes API.
2123
<!-- steps -->
2224

2325
<!--
24-
## Accessing the cluster API
26+
## Accessing the Kubernetes API
2527
2628
### Accessing for the first time with kubectl
2729
-->
28-
## 访问集群 API
30+
## 访问 Kubernetes API
2931

3032
### 使用 kubectl 进行首次访问
3133

@@ -72,8 +74,8 @@ kubectl handles locating and authenticating to the API server. If you want to di
7274
kubectl 处理对 API 服务器的定位和身份验证。如果你想通过 http 客户端(如 `curl``wget`
7375
或浏览器)直接访问 REST API,你可以通过多种方式对 API 服务器进行定位和身份验证:
7476

75-
<!--
76-
1. Run kubectl in proxy mode (recommended). This method is recommended, since it uses the stored apiserver location and verifies the identity of the API server using a self-signed cert. No man-in-the-middle (MITM) attack is possible using this method.
77+
<!--
78+
1. Run kubectl in proxy mode (recommended). This method is recommended, since it uses the stored apiserver location and verifies the identity of the API server using a self-signed cert. No man-in-the-middle (MITM) attack is possible using this method.
7779
1. Alternatively, you can provide the location and credentials directly to the http client. This works with client code that is confused by proxies. To protect against man in the middle attacks, you'll need to import a root cert into your browser.
7880
-->
7981
1. 以代理模式运行 kubectl(推荐)。
@@ -84,7 +86,7 @@ kubectl 处理对 API 服务器的定位和身份验证。如果你想通过 htt
8486
为防止中间人攻击,你需要将根证书导入浏览器。
8587

8688
<!--
87-
Using the Go or Python client libraries provides accessing kubectl in proxy mode.
89+
Using the Go or Python client libraries provides accessing kubectl in proxy mode.
8890
-->
8991
使用 Go 或 Python 客户端库可以在代理模式下访问 kubectl。
9092

@@ -98,7 +100,9 @@ locating the API server and authenticating.
98100

99101
下列命令使 kubectl 运行在反向代理模式下。它处理 API 服务器的定位和身份认证。
100102

101-
<!-- Run it like this: -->
103+
<!--
104+
Run it like this:
105+
-->
102106
像这样运行它:
103107

104108
```shell
@@ -119,7 +123,9 @@ Then you can explore the API with curl, wget, or a browser, like so:
119123
curl http://localhost:8080/api/
120124
```
121125

122-
<!-- The output is similar to this: -->
126+
<!--
127+
The output is similar to this:
128+
-->
123129
输出类似如下:
124130

125131
```json
@@ -184,7 +190,9 @@ TOKEN=$(kubectl get secret default-token -o jsonpath='{.data.token}' | base64 --
184190
curl -X GET $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure
185191
```
186192

187-
<!-- The output is similar to this: -->
193+
<!--
194+
The output is similar to this:
195+
-->
188196
输出类似如下:
189197

190198
```json
@@ -239,7 +247,9 @@ Kubernetes 官方支持 [Go](#go-client)、[Python](#python-client)、[Java](#ja
239247
参考[客户端库](/zh-cn/docs/reference/using-api/client-libraries/)了解如何使用其他语言来访问 API
240248
以及如何执行身份认证。
241249

242-
<!-- #### Go client -->
250+
<!--
251+
#### Go client
252+
-->
243253

244254
#### Go 客户端 {#go-client}
245255

@@ -252,16 +262,16 @@ Kubernetes 官方支持 [Go](#go-client)、[Python](#python-client)、[Java](#ja
252262
参见 [https://github.com/kubernetes/client-go/releases](https://github.com/kubernetes/client-go/releases) 查看受支持的版本。
253263
* 基于 client-go 客户端编写应用程序。
254264

265+
{{< note >}}
255266
<!--
256-
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.
267+
client-go defines its own API objects, so if needed, import API definitions from client-go rather than from the main repository. For example, `import "k8s.io/client-go/kubernetes"` is correct.
257268
-->
258-
{{< note >}}
259-
注意 client-go 定义了自己的 API 对象,因此如果需要,请从 client-go 而不是主仓库导入
269+
client-go 定义了自己的 API 对象,因此如果需要,从 client-go 而不是主仓库导入
260270
API 定义,例如 `import "k8s.io/client-go/kubernetes"` 是正确做法。
261271
{{< /note >}}
262272

263273
<!--
264-
The Go client can use the same [kubeconfig file](/docs/concepts/cluster-administration/authenticate-across-clusters-kubeconfig/)
274+
The Go client can use the same [kubeconfig file](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
265275
as the kubectl CLI does to locate and authenticate to the API server. See this [example](https://git.k8s.io/client-go/examples/out-of-cluster-client-configuration/main.go):
266276
-->
267277
Go 客户端可以使用与 kubectl 命令行工具相同的
@@ -273,11 +283,11 @@ Go 客户端可以使用与 kubectl 命令行工具相同的
273283
package main
274284

275285
import (
276-
"context"
277-
"fmt"
278-
"k8s.io/apimachinery/pkg/apis/meta/v1"
279-
"k8s.io/client-go/kubernetes"
280-
"k8s.io/client-go/tools/clientcmd"
286+
"context"
287+
"fmt"
288+
"k8s.io/apimachinery/pkg/apis/meta/v1"
289+
"k8s.io/client-go/kubernetes"
290+
"k8s.io/client-go/tools/clientcmd"
281291
)
282292

283293
func main() {
@@ -298,7 +308,9 @@ If the application is deployed as a Pod in the cluster, see [Accessing the API f
298308
如果该应用程序部署为集群中的一个
299309
Pod,请参阅[从 Pod 内访问 API](/zh-cn/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod)
300310

301-
<!-- #### Python client -->
311+
<!--
312+
#### Python client
313+
-->
302314
#### Python 客户端 {#python-client}
303315

304316
<!--
@@ -309,7 +321,7 @@ To use [Python client](https://github.com/kubernetes-client/python), run the fol
309321
参见 [Python 客户端库主页](https://github.com/kubernetes-client/python)了解更多安装选项。
310322

311323
<!--
312-
The Python client can use the same [kubeconfig file](/docs/concepts/cluster-administration/authenticate-across-clusters-kubeconfig/)
324+
The Python client can use the same [kubeconfig file](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
313325
as the kubectl CLI does to locate and authenticate to the API server. See this [example](https://github.com/kubernetes-client/python/blob/master/examples/out_of_cluster_config.py):
314326
-->
315327
Python 客户端可以使用与 kubectl 命令行工具相同的
@@ -329,7 +341,9 @@ for i in ret.items:
329341
print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))
330342
```
331343

332-
<!-- #### Java client -->
344+
<!--
345+
#### Java client
346+
-->
333347
#### Java 客户端 {#java-client}
334348

335349
<!--

0 commit comments

Comments
 (0)