arshbot
arshbot

Reputation: 15815

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?

Upvotes: 23

Views: 7571

Answers (1)

arshbot
arshbot

Reputation: 15815

--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

Upvotes: 50

Related Questions