kubectl config view --minify

From wikieduonline
Revision as of 14:18, 7 October 2022 by Welcome (talk | contribs)
Jump to navigation Jump to search

kubectl config view --minify --output 'jsonpath={..namespace}@{.current-context}' 2> /dev/null
k8s_info() {
  kubectl config view --minify --output 'jsonpath={..namespace}@{.current-context}' 2> /dev/null
}

Ref: [1]


APISERVER=$(kubectl config view --minify | grep server | cut -f 2- -d ":" | tr -d " ")
TOKEN=$(kubectl describe secret default-token | grep -E '^token' | cut -f2 -d':' | tr -d " ")

curl $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure

See also

  • https://stackoverflow.com/questions/61406690/bash-kube-context-and-git-branch-prompt
  • Advertising: