Answers for "kubectl list context"

0

kubectl list context

# list kubernets contexts
kubectl config get-contexts
Posted by: Guest on January-14-2021
2

kubectl use context

kubectl config view # Show Merged kubeconfig settings.

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

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}'    # display the first user
kubectl config view -o jsonpath='{.users[*].name}'   # get a list of users
kubectl 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

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

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

# set a context utilizing a specific username and namespace.
kubectl config set-context gce --user=cluster-admin --namespace=foo \
  && kubectl config use-context gce

kubectl config unset users.foo                       # delete user foo
Posted by: Guest on November-26-2020
0

kubectl get pods

# Get pods in default namespace
kubectl get pods

#Get Pods in my-namespace
kubectl get pods -n my-namespace

#Get Pods in all namespaces
kubectl get pods --all-namespaces
Posted by: Guest on October-20-2020

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language