The Answer
Prerequisite
Ensure the cluster API endpoint is accessible.
If kubectl
returns an error like this:
"https://XXXXX.gr7.us-east-1.eks.amazonaws.com/api?timeout=32s": dial tcp 10.0.2.234:443: i/o timeout
...then one possibility preventing you from connecting to the API is API server endpoint access. You can either set it public with a CIDR access list, or must access it from inside the VPC.
see cluster_endpoint_public_access
and associated settings here.
Solution
Ensure the cluster creator has admin permissions.
This may be your issue if kubectl
returns an error like this:
the server has asked for the client to provide credentials
This one is the big "gotcha", since when creating a cluster with eksctl
it takes care of this for you. However, when creating an EKS cluster with Terraform the default for this setting is false
. You need to actively configure it to true
.
enable_cluster_creator_admin_permissions = true
- more info
here
Why did I create this post?
I created this question and answer because when I encountered this problem and researched it all of the answers seemed to assume that the cluster was created through eksctl
and that the cluster creator already had admin privileges.
The answers I found all assumed that you could actually still issue kubectl
and eksctl
commands. In the case where you did not specify enable_cluster_creator_admin_permissions = true
, kubectl
will not work and many eksctl
commands will not work and will fail with an error such as this:
Error: getting auth ConfigMap: Unauthorized
Note that some eksctl
commands will work, as they rely on the Amazon APIs and not the cluster API. For example these will still work
aws eks --region <region>> update-kubeconfig --name <cluster_name>
eksctl get cluster --name <cluster_name>
The part I do not yet understand
If you create an EKS cluster with the enable_cluster_creator_admin_permissions
of false
it appears to me that there is no way forward to reconfiguring your cluster to make it usable.
- You lack the privileges to add a user to
system:masters
through either the AWS console or eksctl create iamidentitymapping
.
- You cannot use
kubectl
and cannot access any resources (Cluster, workload, config, service, etc) through the AWS console.
So my remaining question are:
- What is the use case for creating an EKS cluster with
enable_cluster_creator_admin_permissions = false
?
- And if there are none, why is there even a
enable_cluster_creator_admin_permissions
setting, and why doesn't it default to true
?