Importing EKS cluster kubeconfig using AWS CLI
10 October, 2023
To fetch the kubeconfig
of your AWS EKS cluster you need the two things:
- aws-cli installed on your machine
- AWS credentials configured
I have a global venv which I activate from my home directory.
$ . ~/.venv/bin/activate.fish
$ pip install awscli
In case my ~/.aws/credentials
file isn’t populated I’ll export the environment variables.
$ export AWS_ACCESS_KEY_ID=YOUR_KEY
$ export AWS_SECRET_ACCESS_KEY=YOUR_SECRET
Once I have these two things in set up, I’d use aws eks
subcommand to import the kubeconfig
.
$ aws eks update-kubeconfig --region [CLUSTER_REGION] --name [CLUSTER_NAME]
Updated context arn:aws:eks:eu-west-2:ARN:cluster/mothership in ~/.kube/config
With this, the kubeconfig
should be updated in our home directory ~/.kube/config
and we should be able to query our cluster.
$ kubectl get pods -n kube-system