From c48f0757a3a2710df273767152d93f89e8748626 Mon Sep 17 00:00:00 2001 From: Anna Nguyen Date: Thu, 7 Mar 2019 16:12:14 -0600 Subject: [PATCH] =?UTF-8?q?Clarified=20step=20of=20getting=20Kubernetes=20?= =?UTF-8?q?cluster=20name;=20fixed=20quoting=20in=20c=E2=80=A6=20(#12718)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Clarified step of getting Kubernetes cluster name; fixed quoting in command that sets `APISERVER`. Need to set `CLUSTER_NAME` before using it. The single quote in the `APISERVER` command prevented the expansion of the `CLUSTER_NAME` variable. * Remove whitespace --- .../tasks/administer-cluster/access-cluster-api.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/content/en/docs/tasks/administer-cluster/access-cluster-api.md b/content/en/docs/tasks/administer-cluster/access-cluster-api.md index 55b84d5daab64..16434ca0a4563 100644 --- a/content/en/docs/tasks/administer-cluster/access-cluster-api.md +++ b/content/en/docs/tasks/administer-cluster/access-cluster-api.md @@ -87,12 +87,15 @@ directly to the API server, like this: Using `grep/cut` approach: -``` shell -# Check all possible clusters, as you .KUBECONFIG may have multiple contexts -kubectl config view -o jsonpath='{range .clusters[*]}{.name}{"\t"}{.cluster.server}{"\n"}{end}' +```shell +# Check all possible clusters, as you .KUBECONFIG may have multiple contexts: +kubectl config view -o jsonpath='{"Cluster name\tServer\n"}{range .clusters[*]}{.name}{"\t"}{.cluster.server}{"\n"}{end}' + +# Select name of cluster you want to interact with from above output: +export CLUSTER_NAME="some_server_name" # Point to the API server refering the cluster name -APISERVER=$(kubectl config view -o jsonpath='{.clusters[?(@.name=="$CLUSTER_NAME")].cluster.server}') +APISERVER=$(kubectl config view -o jsonpath="{.clusters[?(@.name==\"$CLUSTER_NAME\")].cluster.server}") # Gets the token value TOKEN=$(kubectl get secrets -o jsonpath="{.items[?(@.metadata.annotations['kubernetes\.io/service-account\.name']=='default')].data.token}"|base64 -d)