-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zh: add content_zh/boilerplates/kubectl-multicluster-contexts.md (#3649)
- Loading branch information
1 parent
e44c708
commit 3fd7ce5
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 >}} |