https://kubernetes.io/docs/reference/kubectl/cheatsheet/

kubectl context and configuration

kubectl config view # show merged kubeconfig settings

# use multiple kubeconfig files at the same time and view merged config
KUBECONIG=~/.kube/config:~/.kube/kubeconfig2

kubectl config view

# get the password for the e2e user
kubectl config view -o jsonpath='{.users[?(@.name == "e2e")].user.password}'

kubectl config view -o jsonpath='{.users[].name}' # disply the first user
kubectl config view -o jsonpath='{.users[*].name}' # get a list of users
kuvectl config get-contexts # display list of contexts
kubectl config current-context # display the current context
kubectl config use-context my-cluster-name # set the default context to my-cluster-name

kubectl config set-cluster my-cluster-name # set a cluster entry in the kubeconfig

# configure the URL to a proxy server to use for requests made by this client in the kubeconfig
kubectl config set-cluster my-cluster-name --proxy-url=my-proxy-url

# add a new user to your kubeconf that supprorts basic auth
kubectl config set-credentials kubeuser/foo.kubernetes.com --username=kubeuser --password=kubepassword

# permanently save the namespace for all subsequent kubectl command in that context.
k config set-contexy --current --namespace=ggckad-s2

# set a context utilizing a sepecific username and namespace
kubectl config set-context gce ---user=cluster-admin --namespace=foo \\
kubectl congif use-context gce

kubectl config unset users.foo