Skip to content

Commit

Permalink
Clarified step of getting Kubernetes cluster name; fixed quoting in c… (
Browse files Browse the repository at this point in the history
kubernetes#12718)

* 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
  • Loading branch information
aqnaqn authored and Mayank Kumar committed Mar 11, 2019
1 parent b00b76c commit c48f075
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions content/en/docs/tasks/administer-cluster/access-cluster-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c48f075

Please sign in to comment.