HomePostsAWS EKS + Kubeconfig

AWS EKS + Kubeconfig

Dec 13, 2022
0 minutes read

Update kubeconfig

Create kube config file using aws eks update-kubeconfig. Make sure to define the variable KUBECONFIG that points to your desired kube config location.

KUBECONFIG=/path/to/config \
aws eks update-kubeconfig \
--region <region> \
--name <cluster-name>

If you successfully update the config, you will see a output log like this:

Added new context arn:aws:eks:...:cluster/cluster-name to /path/to/config

Merge config files

KUBECONFIG=/path/to/config-1:/path/to/config-2 \
kubectl config view --flatten > ~/.kube/config

Switch between clusters

First, we can list the current context with get-contexts command

kubectl config get-contexts

This will show you the available clusters that you are connected to.

To switch contexts, run the command use-context with one of the available contexts.

kubectl config use-context <context-name>