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
+62-29Lines changed: 62 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ weight: 60
14
14
<!--
15
15
This page shows how to access clusters using the Kubernetes API.
16
16
-->
17
-
本页展示了如何使用 Kubernetes API 访问集群
17
+
本页展示了如何使用 Kubernetes API 访问集群。
18
18
19
19
## {{% heading "prerequisites" %}}
20
20
@@ -35,7 +35,7 @@ This page shows how to access clusters using the Kubernetes API.
35
35
When accessing the Kubernetes API for the first time, use the
36
36
Kubernetes command-line tool, `kubectl`.
37
37
-->
38
-
首次访问 Kubernetes API 时,请使用 Kubernetes 命令行工具 `kubectl`。
38
+
首次访问 Kubernetes API 时,请使用 Kubernetes 命令行工具 `kubectl`。
39
39
40
40
<!--
41
41
To access a cluster, you need to know the location of the cluster and have credentials
@@ -71,12 +71,16 @@ kubectl handles locating and authenticating to the API server. If you want to di
71
71
-->
72
72
### 直接访问 REST API
73
73
74
-
kubectl 处理对 API 服务器的定位和身份验证。如果你想通过 http 客户端(如 `curl` 或 `wget`,
74
+
kubectl 处理对 API 服务器的定位和身份验证。如果你想通过 http 客户端(如 `curl`、`wget`
75
75
或浏览器)直接访问 REST API,你可以通过多种方式对 API 服务器进行定位和身份验证:
76
76
77
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.
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
+
1. Run kubectl in proxy mode (recommended). This method is recommended, since it uses
79
+
the stored apiserver location and verifies the identity of the API server using a
80
+
self-signed cert. No man-in-the-middle (MITM) attack is possible using this method.
81
+
1. Alternatively, you can provide the location and credentials directly to the http client.
82
+
This works with client code that is confused by proxies. To protect against man in the
83
+
middle attacks, you'll need to import a root cert into your browser.
80
84
-->
81
85
1. 以代理模式运行 kubectl(推荐)。
82
86
推荐使用此方法,因为它用存储的 apiserver 位置并使用自签名证书验证 API 服务器的标识。
@@ -86,7 +90,7 @@ kubectl 处理对 API 服务器的定位和身份验证。如果你想通过 htt
86
90
为防止中间人攻击,你需要将根证书导入浏览器。
87
91
88
92
<!--
89
-
Using the Go or Python client libraries provides accessing kubectl in proxy mode.
93
+
Using the Go or Python client libraries provides accessing kubectl in proxy mode.
90
94
-->
91
95
使用 Go 或 Python 客户端库可以在代理模式下访问 kubectl。
92
96
@@ -237,7 +241,11 @@ describes how you can configure this as a cluster administrator.
237
241
<!--
238
242
### Programmatic access to the API
239
243
240
-
Kubernetes officially supports client libraries for [Go](#go-client), [Python](#python-client), [Java](#java-client), [dotnet](#dotnet-client), [JavaScript](#javascript-client), and [Haskell](#haskell-client). There are other client libraries that are provided and maintained by their authors, not the Kubernetes team. See [client libraries](/docs/reference/using-api/client-libraries/) for accessing the API from other languages and how they authenticate.
244
+
Kubernetes officially supports client libraries for [Go](#go-client), [Python](#python-client),
245
+
[Java](#java-client), [dotnet](#dotnet-client), [JavaScript](#javascript-client), and
246
+
[Haskell](#haskell-client). There are other client libraries that are provided and maintained by
247
+
their authors, not the Kubernetes team. See [client libraries](/docs/reference/using-api/client-libraries/)
248
+
for accessing the API from other languages and how they authenticate.
* To get the library, run the following command: `go get k8s.io/client-go@kubernetes-<kubernetes-version-number>` See [https://github.com/kubernetes/client-go/releases](https://github.com/kubernetes/client-go/releases) to see which versions are supported.
265
+
* To get the library, run the following command: `go get k8s.io/client-go@kubernetes-<kubernetes-version-number>`
266
+
See [https://github.com/kubernetes/client-go/releases](https://github.com/kubernetes/client-go/releases)
267
+
to see which versions are supported.
258
268
* Write an application atop of the client-go clients.
259
269
-->
260
270
261
271
* 要获取库,运行下列命令:`go get k8s.io/client-go/kubernetes-<kubernetes 版本号>`,
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.
278
+
client-go defines its own API objects, so if needed, import API definitions from client-go rather than
279
+
from the main repository. For example, `import "k8s.io/client-go/kubernetes"` is correct.
268
280
-->
269
281
client-go 定义了自己的 API 对象,因此如果需要,从 client-go 而不是主仓库导入
270
282
API 定义,例如 `import "k8s.io/client-go/kubernetes"` 是正确做法。
@@ -303,7 +315,8 @@ func main() {
303
315
```
304
316
305
317
<!--
306
-
If the application is deployed as a Pod in the cluster, see [Accessing the API from within a Pod](/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod).
318
+
If the application is deployed as a Pod in the cluster, see
319
+
[Accessing the API from within a Pod](/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod).
307
320
-->
308
321
如果该应用程序部署为集群中的一个
309
322
Pod,请参阅[从 Pod 内访问 API](/zh-cn/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod)。
@@ -314,15 +327,18 @@ Pod,请参阅[从 Pod 内访问 API](/zh-cn/docs/tasks/access-application-clus
314
327
#### Python 客户端 {#python-client}
315
328
316
329
<!--
317
-
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.
330
+
To use [Python client](https://github.com/kubernetes-client/python), run the following command:
331
+
`pip install kubernetes`. See [Python Client Library page](https://github.com/kubernetes-client/python)
The Python client can use the same [kubeconfig file](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
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):
340
+
as the kubectl CLI does to locate and authenticate to the API server. See this
See [https://github.com/kubernetes-client/java/releases](https://github.com/kubernetes-client/java/releases) to see which versions are supported.
380
+
See [https://github.com/kubernetes-client/java/releases](https://github.com/kubernetes-client/java/releases)
381
+
to see which versions are supported.
365
382
366
383
The Java client can use the same [kubeconfig file](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
367
-
as the kubectl CLI does to locate and authenticate to the API server. See this [example](https://github.com/kubernetes-client/java/blob/master/examples/examples-release-15/src/main/java/io/kubernetes/client/examples/KubeConfigFileClientExample.java):
384
+
as the kubectl CLI does to locate and authenticate to the API server. See this
@@ -424,21 +442,28 @@ public class KubeConfigFileClientExample {
424
442
<!--
425
443
#### dotnet client
426
444
427
-
To use [dotnet client](https://github.com/kubernetes-client/csharp), run the following command: `dotnet add package KubernetesClient --version 1.6.1` See [dotnet Client Library page](https://github.com/kubernetes-client/csharp) for more installation options. See [https://github.com/kubernetes-client/csharp/releases](https://github.com/kubernetes-client/csharp/releases) to see which versions are supported.
445
+
To use [dotnet client](https://github.com/kubernetes-client/csharp),
446
+
run the following command: `dotnet add package KubernetesClient --version 1.6.1`
447
+
See [dotnet Client Library page](https://github.com/kubernetes-client/csharp)
The dotnet client can use the same [kubeconfig file](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
430
-
as the kubectl CLI does to locate and authenticate to the API server. See this [example](https://github.com/kubernetes-client/csharp/blob/master/examples/simple/PodList.cs):
453
+
as the kubectl CLI does to locate and authenticate to the API server. See this
To install [JavaScript client](https://github.com/kubernetes-client/javascript), run the following command: `npm install @kubernetes/client-node`. See [https://github.com/kubernetes-client/javascript/releases](https://github.com/kubernetes-client/javascript/releases) to see which versions are supported.
499
+
To install [JavaScript client](https://github.com/kubernetes-client/javascript),
500
+
run the following command: `npm install @kubernetes/client-node`. See
The JavaScript client can use the same [kubeconfig file](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
477
-
as the kubectl CLI does to locate and authenticate to the API server. See this [example](https://github.com/kubernetes-client/javascript/blob/master/examples/example.js):
505
+
as the kubectl CLI does to locate and authenticate to the API server. See this
See [https://github.com/kubernetes-client/haskell/releases](https://github.com/kubernetes-client/haskell/releases) to see which versions are supported.
535
+
See [https://github.com/kubernetes-client/haskell/releases](https://github.com/kubernetes-client/haskell/releases)
536
+
to see which versions are supported.
507
537
508
-
The [Haskell client](https://github.com/kubernetes-client/haskell) can use the same [kubeconfig file](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
509
-
as the kubectl CLI does to locate and authenticate to the API server. See this [example](https://github.com/kubernetes-client/haskell/blob/master/kubernetes-client/example/App.hs):
538
+
The [Haskell client](https://github.com/kubernetes-client/haskell) can use the same
0 commit comments