I am testing role differences right now so I have a context for each role setup.
Terminal session Admin, I want to be able to use context Admin in one session so I can update the rules as needed.
In terminal session User, I want to be able to test that role via its context.
(Note: I am on EKS so roles map to IAM roles)
Well, I am an idiot.
Natively, there is no answer in the --help output for kubectl; however, there is output for this in the man page.
All one has to do is throw the --context flag into their command.
However, the below-mentioned kubectx tool is what I use day to day now.
Here are some tips for managing multiple kubectl contexts:
asdf to manage multiple kubectl versionsKUBECONFIG env var to change between multiple kubeconfig fileskube-ps1 to keep track of your current context/namespacekubectx and kubens to change fast between clusters/namespacesTake a look at this article, it explains how to accomplish this: Using different kubectl versions with multiple Kubernetes clusters (Disclaimer: I wrote the mentioned article)
I also recommend this reads: Mastering the KUBECONFIG file and Configure Access to Multiple Clusters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With