Clarified step of getting Kubernetes cluster name; fixed quoting in c… (#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
This commit is contained in:
committed by
Kubernetes Prow Robot
parent
2ee8a94c5d
commit
d110471a35
@@ -87,12 +87,15 @@ directly to the API server, like this:
|
|||||||
|
|
||||||
Using `grep/cut` approach:
|
Using `grep/cut` approach:
|
||||||
|
|
||||||
``` shell
|
```shell
|
||||||
# Check all possible clusters, as you .KUBECONFIG may have multiple contexts
|
# Check all possible clusters, as you .KUBECONFIG may have multiple contexts:
|
||||||
kubectl config view -o jsonpath='{range .clusters[*]}{.name}{"\t"}{.cluster.server}{"\n"}{end}'
|
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
|
# 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
|
# Gets the token value
|
||||||
TOKEN=$(kubectl get secrets -o jsonpath="{.items[?(@.metadata.annotations['kubernetes\.io/service-account\.name']=='default')].data.token}"|base64 -d)
|
TOKEN=$(kubectl get secrets -o jsonpath="{.items[?(@.metadata.annotations['kubernetes\.io/service-account\.name']=='default')].data.token}"|base64 -d)
|
||||||
|
|||||||
Reference in New Issue
Block a user