Difference between revisions of "Kubectl config view --minify"

From wikieduonline
Jump to navigation Jump to search
(Removed redirect to Kubectl config view)
Tag: Removed redirect
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{lc}}
  
 +
[[kubectl config view --minify --output]] '[[jsonpath]]={..namespace}@{.current-context}' 2> /dev/null
  
  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: <ref>https://stackoverflow.com/questions/61406690/bash-kube-context-and-git-branch-prompt</ref>
  
  
 +
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
 +
Ref: https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/
 +
 +
== See also ==
 
* {{kubectl config view}}
 
* {{kubectl config view}}
 +
* {{kubectl config}}
 +
 +
[[Category:K8s]]

Latest revision as of 14:19, 7 October 2022

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
Ref: https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/

See also[edit]

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