Unfortunately, AWS doesn't yet have a command like GKE's "gcloud container clusters get-credentials", which creates kubectl config for you. So, you need to create kubectl config file manually.
As mentioned in creating a kubeconfig for Amazon EKS document, you should get two things from the cluster:
Retrieve the endpoint for your cluster. Use this for the
<endpoint-url> in your kubeconfig file.
aws eks describe-cluster --cluster-name <cluster-name> --query cluster.endpoint
Retrieve the certificateAuthority.data for your cluster. Use this for the
<base64-encoded-ca-cert> in your kubeconfig file.
aws eks describe-cluster --cluster-name <cluster-name> --query cluster.certificateAuthority.data
Create the default kubectl folder if it does not already exist.
mkdir -p ~/.kube
Open your favorite text editor and paste the following kubeconfig code block into it.
- name: aws
# - "-r"
# - "<role-arn>"
# - name: AWS_PROFILE
# value: "<aws-profile>"
<endpoint-url> with the endpoint URL that was created for your cluster.
<base64-encoded-ca-cert> with the certificateAuthority.data that was created for your cluster.
<cluster-name> with your cluster name.
Save the file to the default kubectl folder, with your cluster name in the file name. For example, if your cluster name is devel, save the file to
Add that file path to your
KUBECONFIG environment variable so that
kubectl knows where to look for your cluster configuration.
(Optional) Add the configuration to your shell initialization file so that it is configured when you open a shell.
For Bash shells on macOS:
echo 'export KUBECONFIG=$KUBECONFIG:~/.kube/config-devel' >> ~/.bash_profile
For Bash shells on Linux:
echo 'export KUBECONFIG=$KUBECONFIG:~/.kube/config-devel' >> ~/.bashrc
Test your configuration.
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 1m
If you receive the error
"heptio-authenticator-aws": executable file not found in $PATH, then your
kubectl is not configured for Amazon EKS. For more information, see Configure kubectl for Amazon EKS.