How can you speed up switching between namespaces using kubectl?
Experience Level: Medior
Tags: Kubernetes
Answer
Option 1:
Create alias and variable:
alias k=kubectl
export n="config set-context --current --namespace"
Then switch namespace like this:
k $n=default
Option 2:
Create two aliases
alias k=kubectl
alias kn="kubectl config set-context --current --namespace"
Then switch namespace like this:
kn default
Related Kubernetes job interview questions
What does kubectl cordon do?
Kubernetes JuniorHow do you find Kubernetes pods that consume the most CPU?
Kubernetes JuniorHow can you speed up your work flow when using kubectl?
Kubernetes JuniorHow do you get all events that Kubernetes logged for a pod with name pod1?
Kubernetes JuniorWhat command can you use to get the address of the Kubernetes control plane and cluster services?
Kubernetes Junior