How to create a kubeconfig
file for an existing EKS Cluster?
Step-1:
Install aws-cli
on your machine using the following script:
#!/bin/bash curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install aws --version
Step-2:
Run aws configure
command to set up aws credentials:
$ aws configure AWS Access Key ID [None]: <AccessID> AWS Secret Access Key [None]: <AccessKey> Default region name [None]: <Region> Default output format [None]: <Format, e.g:json>
Step-3:
Create kubeconfig
file on ~/.kube/config
location:
$ aws eks update-kubeconfig --name <EKS_CLUSTER_NAME> \ --region <REGION_CODE>
Run:
$ aws eks update-kubeconfig --name cluster-1 --region ap-northeast-1 $ cat ~/.kube/config
Bonus: How to list all existing EKS Cluster ?
$ aws eks list-clusters --region <AWS-REGION> $ aws eks list-clusters --region ap-northeast-1
Output:
{ "clusters": [ "Cluster-1", "Cluster-2" ] }
Query Cluster Name:
$ EKS_CLUSTER_NAME=$(aws eks list-clusters --region ap-northeast-1 --query clusters[0] --output text) $ echo $EKS_CLUSTER_NAME
Output:
Cluster-1
Top comments (0)