Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a command against a specific context with kubectl?

I have multiple contexts and I want to be able to run commands against a context that I have access to but am not pointed to, while in another context.

How do I run a command, say $ kubectl get pods against context B while I'm currently pointed to context A?

like image 966
arshbot Avatar asked May 01 '19 15:05

arshbot


1 Answers

--context is a global option for all kubectl commands. Simply run:

$ kubectl get pods --context <context_B>

For a list of all global kubectl options, run $ kubectl options

like image 71
arshbot Avatar answered Nov 18 '22 04:11

arshbot