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-cn/docs/tasks/administer-cluster/access-cluster-api.md
+35-21Lines changed: 35 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,12 @@
1
1
---
2
2
title: 使用 Kubernetes API 访问集群
3
3
content_type: task
4
+
weight: 60
4
5
---
5
6
<!--
6
7
title: Access Clusters Using the Kubernetes API
7
8
content_type: task
9
+
weight: 60
8
10
-->
9
11
10
12
<!-- overview -->
@@ -21,11 +23,11 @@ This page shows how to access clusters using the Kubernetes API.
21
23
<!-- steps -->
22
24
23
25
<!--
24
-
## Accessing the cluster API
26
+
## Accessing the Kubernetes API
25
27
26
28
### Accessing for the first time with kubectl
27
29
-->
28
-
## 访问集群 API
30
+
## 访问 Kubernetes API
29
31
30
32
### 使用 kubectl 进行首次访问
31
33
@@ -72,8 +74,8 @@ kubectl handles locating and authenticating to the API server. If you want to di
72
74
kubectl 处理对 API 服务器的定位和身份验证。如果你想通过 http 客户端(如 `curl` 或 `wget`,
73
75
或浏览器)直接访问 REST API,你可以通过多种方式对 API 服务器进行定位和身份验证:
74
76
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.
77
79
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.
78
80
-->
79
81
1. 以代理模式运行 kubectl(推荐)。
@@ -84,7 +86,7 @@ kubectl 处理对 API 服务器的定位和身份验证。如果你想通过 htt
84
86
为防止中间人攻击,你需要将根证书导入浏览器。
85
87
86
88
<!--
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.
88
90
-->
89
91
使用 Go 或 Python 客户端库可以在代理模式下访问 kubectl。
90
92
@@ -98,7 +100,9 @@ locating the API server and authenticating.
98
100
99
101
下列命令使 kubectl 运行在反向代理模式下。它处理 API 服务器的定位和身份认证。
100
102
101
-
<!-- Run it like this: -->
103
+
<!--
104
+
Run it like this:
105
+
-->
102
106
像这样运行它:
103
107
104
108
```shell
@@ -119,7 +123,9 @@ Then you can explore the API with curl, wget, or a browser, like so:
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.
257
268
-->
258
-
{{< note >}}
259
-
注意 client-go 定义了自己的 API 对象,因此如果需要,请从 client-go 而不是主仓库导入
269
+
client-go 定义了自己的 API 对象,因此如果需要,从 client-go 而不是主仓库导入
260
270
API 定义,例如 `import "k8s.io/client-go/kubernetes"` 是正确做法。
261
271
{{< /note >}}
262
272
263
273
<!--
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/)
265
275
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):
266
276
-->
267
277
Go 客户端可以使用与 kubectl 命令行工具相同的
@@ -273,11 +283,11 @@ Go 客户端可以使用与 kubectl 命令行工具相同的
273
283
package main
274
284
275
285
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"
281
291
)
282
292
283
293
funcmain() {
@@ -298,7 +308,9 @@ If the application is deployed as a Pod in the cluster, see [Accessing the API f
298
308
如果该应用程序部署为集群中的一个
299
309
Pod,请参阅[从 Pod 内访问 API](/zh-cn/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod)。
300
310
301
-
<!-- #### Python client -->
311
+
<!--
312
+
#### Python client
313
+
-->
302
314
#### Python 客户端 {#python-client}
303
315
304
316
<!--
@@ -309,7 +321,7 @@ To use [Python client](https://github.com/kubernetes-client/python), run the fol
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/)
313
325
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):
0 commit comments