Skip to content
Advertisement

Create Multiple Virtual envs for Multiple kubernetes contexts

As of now i do

JavaScript

to get pod in specific cluster

is there a python way to set kubernetes context for a virtual env , so we can use multiple context at the same time example :

JavaScript

This should be equivalent of

JavaScript

Advertisement

Answer

This isn’t probably a rational solution, but anyway… At some time I used different kubectl versions for different clusters and I came up with a venv-like solution to switch between them. I wrote text files like this:

JavaScript

And activated them in the same fashion as venv: source the_file. If you can split your contexts to separate files, you can add export KUBECONFIG="/path/to/kubeconfig" to your venv/bin/activate and it will use the desired config when you activate the venv.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement