Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zh: add content_zh/boilerplates/kubectl-multicluster-contexts.md #3649

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions content_zh/boilerplates/kubectl-multicluster-contexts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
* `kubectl` 能通过 `--context` 参数切换上下文,以支持对不同集群 `cluster1` 和 `cluster2` 的访问。
使用如下命令列出现存的上下文:

{{< text bash >}}
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* cluster1 cluster1 user@foo.com default
cluster2 cluster2 user@foo.com default
{{< /text >}}

* 使用配置的上下文名称导出以下环境变量:

{{< text bash >}}
$ export CTX_CLUSTER1=<KUBECONFIG_CONTEXT_NAME_FOR_CLUSTER_1>
$ export CTX_CLUSTER2=<KUBECONFIG_CONTEXT_NAME_FOR_CLUSTER_2>
{{< /text >}}