Managing kubectl profiles
Thanks to @shmanubhav:
- Save your
~/.kube/config
- Create a new
~/.kube/config
, e.g. withaws eks update-kubeconfig --region us-east-1 --name test
, replace region and name as needed. mv ~/.kube/config ~/.kube/dev-config
export KUBECONFIG=~/.kube/dev-config
- Verify that it worked:
kubectl get nodes
- Use
k9s
Prerequisites
Setup aws-vault, create profile(s), e.g.
dev-from-security
.
Create the kubeconfig files per account
aws-vault exec dev-from-security -- aws eks update-kubeconfig --region us-east-1 --name test --kubeconfig $HOME/.kube/dev-config
Autopick the right kubeconfig
Add this to your .zshenv
case "$AWS_VAULT" in
"dev-from-security" )
export KUBECONFIG="$HOME/.kube/dev-config" ;;
*)
export KUBECONFIG="$HOME/.kube/config" ;;
esac
Use it
Login into your AWS IAM account:
aws-vault exec --duration=12h dev-from-security
A sub-shell is created with AWS*
and KUBECONFIG
env variables set.