Last active
September 11, 2019 08:02
-
-
Save andrijac/176e38792509cacff8b0660cf1977bc0 to your computer and use it in GitHub Desktop.
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
# https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/#without-kubectl-proxy | |
# 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}") | |
# Gets the token value | |
TOKEN=$(kubectl get secrets -o jsonpath="{.items[?(@.metadata.annotations['kubernetes\.io/service-account\.name']=='default')].data.token}"|base64 -d) | |
# Explore the API with TOKEN | |
curl -X GET $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure | |
curl -X GET $APISERVER/api/v1/namespaces/default/pods/ --header "Authorization: Bearer $TOKEN" --insecure | jq '.items[] | select(.metadata.name | contains("data-job-"))' | jq '.status.phase' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment