From ea3b2874a24ffb305a5268a2fb5095a5086f0e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E6=9D=B0=E9=B2=81?= Date: Sat, 2 Apr 2022 11:54:46 +0800 Subject: [PATCH] docs: Resync kubeconfig docs --- .../organize-cluster-access-kubeconfig.md | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/content/zh/docs/concepts/configuration/organize-cluster-access-kubeconfig.md b/content/zh/docs/concepts/configuration/organize-cluster-access-kubeconfig.md index 023046d413..9ce91ed7ce 100644 --- a/content/zh/docs/concepts/configuration/organize-cluster-access-kubeconfig.md +++ b/content/zh/docs/concepts/configuration/organize-cluster-access-kubeconfig.md @@ -32,7 +32,7 @@ It does not mean that there is a file named `kubeconfig`. @@ -96,7 +96,7 @@ clusters and namespaces. A *context* element in a kubeconfig file is used to group access parameters under a convenient name. Each context has three parameters: cluster, namespace, and user. By default, the `kubectl` command-line tool uses parameters from -the *current context* to communicate with the cluster. +the *current context* to communicate with the cluster. --> 通过 kubeconfig 文件中的 *context* 元素,使用简便的名称来对访问参数进行分组。每个上下文都有三个参数:cluster、namespace 和 user。默认情况下,`kubectl` 命令行工具使用 *当前上下文* 中的参数与集群进行通信。 @@ -104,7 +104,8 @@ the *current context* to communicate with the cluster. To choose the current context: --> 选择当前上下文 -``` + +```shell kubectl config use-context ``` @@ -175,7 +176,7 @@ Here are the rules that `kubectl` uses when it merges kubeconfig files: Even if the second file has non-conflicting entries under `red-user`, discard them. --> 1. 如果设置了 `--kubeconfig` 参数,则仅使用指定的文件。不进行合并。此参数只能使用一次。 - + 否则,如果设置了 `KUBECONFIG` 环境变量,将它用作应合并的文件列表。根据以下规则合并 `KUBECONFIG` 环境变量中列出的文件: * 忽略空文件名。 @@ -280,6 +281,34 @@ kubeconfig 文件中的文件和路径引用是相对于 kubeconfig 文件的位 命令行上的文件引用是相对于当前工作目录的。 在 `$HOME/.kube/config` 中,相对路径按相对路径存储,绝对路径按绝对路径存储。 + +## 代理 + +你可以在 `kubeconfig` 文件中设置 `proxy-url` 来为 `kubectl` 使用代理,例如: + +```yaml +apiVersion: v1 +kind: Config + +proxy-url: https://proxy.host:3128 + +clusters: +- cluster: + name: development + +users: +- name: developer + +contexts: +- context: + name: development + +``` + ## {{% heading "whatsnext" %}} * [配置对多集群的访问](/zh/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) * [`kubectl config`](/docs/reference/generated/kubectl/kubectl-commands#config) -