zh-translation: boilerplates/kubectl-multicluster-contexts.md (#9807)

This commit is contained in:
orangegzx 2021-05-25 22:01:11 +08:00 committed by GitHub
parent c5d6e2c8e4
commit 39ed89926c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -1,8 +1,8 @@
---
---
* 可以使用 `kubectl` 命令带上 `--context` 参数去访问集群 `cluster1``cluster2`
* 可以使用 `kubectl` 命令带上 `--context` 参数去访问集群 `cluster1``cluster2`
例如 `kubectl get pods --context cluster1`
使用如下命令列出你的上下文:
使用如下命令列出您的上下文:
{{< text bash >}}
$ kubectl config get-contexts
@ -11,15 +11,15 @@
cluster2 cluster2 user@foo.com default
{{< /text >}}
* 保存集群的上下文到环境变量:
* 保存集群的上下文到环境变量
{{< text bash >}}
$ export CTX_CLUSTER1=$(kubectl config view -o jsonpath='{.contexts[0].name}')
$ export CTX_CLUSTER2=$(kubectl config view -o jsonpath='{.contexts[1].name}')
$ echo CTX_CLUSTER1 = ${CTX_CLUSTER1}, CTX_CLUSTER2 = ${CTX_CLUSTER2}
$ echo "CTX_CLUSTER1 = ${CTX_CLUSTER1}, CTX_CLUSTER2 = ${CTX_CLUSTER2}"
CTX_CLUSTER1 = cluster1, CTX_CLUSTER2 = cluster2
{{< /text >}}
{{< tip >}}
如果你有超过两个集群的上下文并且你想要使用前两个以外的集群配置你的网格,你需要手动将环境变量设置为你需要的上下文名称。
如果您有超过两个集群的上下文并且您想要使用前两个以外的集群配置您的网格,您需要手动将环境变量设置为您需要的上下文名称。
{{< /tip >}}