@@ -32,7 +32,7 @@ It does not mean that there is a file named `kubeconfig`.
32
32
33
33
<!--
34
34
{{< warning >}}
35
- Only use kubeconfig files from trusted sources. Using a specially-crafted kubeconfig file could result in malicious code execution or file exposure.
35
+ Only use kubeconfig files from trusted sources. Using a specially-crafted kubeconfig file could result in malicious code execution or file exposure.
36
36
If you must use an untrusted kubeconfig file, inspect it carefully first, much as you would a shell script.
37
37
{{< /warning>}}
38
38
-->
@@ -96,15 +96,16 @@ clusters and namespaces.
96
96
A *context* element in a kubeconfig file is used to group access parameters
97
97
under a convenient name. Each context has three parameters: cluster, namespace, and user.
98
98
By default, the `kubectl` command-line tool uses parameters from
99
- the *current context* to communicate with the cluster.
99
+ the *current context* to communicate with the cluster.
100
100
-->
101
101
通过 kubeconfig 文件中的 * context* 元素,使用简便的名称来对访问参数进行分组。每个上下文都有三个参数:cluster、namespace 和 user。默认情况下,` kubectl ` 命令行工具使用 * 当前上下文* 中的参数与集群进行通信。
102
102
103
103
<!--
104
104
To choose the current context:
105
105
-->
106
106
选择当前上下文
107
- ```
107
+
108
+ ``` shell
108
109
kubectl config use-context
109
110
```
110
111
@@ -175,7 +176,7 @@ Here are the rules that `kubectl` uses when it merges kubeconfig files:
175
176
Even if the second file has non-conflicting entries under `red-user`, discard them.
176
177
-->
177
178
1 . 如果设置了 ` --kubeconfig ` 参数,则仅使用指定的文件。不进行合并。此参数只能使用一次。
178
-
179
+
179
180
否则,如果设置了 ` KUBECONFIG ` 环境变量,将它用作应合并的文件列表。根据以下规则合并 ` KUBECONFIG ` 环境变量中列出的文件:
180
181
181
182
* 忽略空文件名。
@@ -280,6 +281,34 @@ kubeconfig 文件中的文件和路径引用是相对于 kubeconfig 文件的位
280
281
命令行上的文件引用是相对于当前工作目录的。
281
282
在 ` $HOME/.kube/config ` 中,相对路径按相对路径存储,绝对路径按绝对路径存储。
282
283
284
+ <!--
285
+ ## Proxy
286
+
287
+ You can configure `kubectl` to use proxy by setting `proxy-url` in the kubeconfig file, like:
288
+ -->
289
+ ## 代理
290
+
291
+ 你可以在 ` kubeconfig ` 文件中设置 ` proxy-url ` 来为 ` kubectl ` 使用代理,例如:
292
+
293
+ ``` yaml
294
+ apiVersion : v1
295
+ kind : Config
296
+
297
+ proxy-url : https://proxy.host:3128
298
+
299
+ clusters :
300
+ - cluster :
301
+ name : development
302
+
303
+ users :
304
+ - name : developer
305
+
306
+ contexts :
307
+ - context :
308
+ name : development
309
+
310
+ ```
311
+
283
312
## {{% heading "whatsnext" %}}
284
313
285
314
<!--
@@ -288,4 +317,3 @@ kubeconfig 文件中的文件和路径引用是相对于 kubeconfig 文件的位
288
317
--->
289
318
* [ 配置对多集群的访问] ( /zh/docs/tasks/access-application-cluster/configure-access-multiple-clusters/ )
290
319
* [ ` kubectl config ` ] ( /docs/reference/generated/kubectl/kubectl-commands#config )
291
-
0 commit comments