4

Say we have a couple of clusters on Amazon EKS. We have a new user or new machine that needs .kube/config to be populated with the latest cluster info.

Is there some easy way we get the context info from our clusters on EKS and put the info in the .kube/config file? something like:

eksctl init "cluster-1-ARN" "cluster-2-ARN"

so after some web-sleuthing, I heard about:

aws eks update-kubeconfig

I tried that, and I get this:

$ aws eks update-kubeconfig usage: aws [options] [ ...] [parameters] To see help text, you can run:

aws help aws help aws help

aws: error: argument --name is required

I would think it would just update for all clusters then, but it don't. So I put the cluster names/ARNs, like so:

aws eks update-kubeconfig --name arn:aws:eks:us-west-2:913xxx371:cluster/eks-cluster-1
aws eks update-kubeconfig --name arn:aws:eks:us-west-2:913xxx371:cluster/ignitecluster

but then I get:

kbc stderr: An error occurred (ResourceNotFoundException) when calling the DescribeCluster operation: No cluster found for name: arn:aws:eks:us-west-2:913xxx371:cluster/eks-cluster-1.
kbc stderr: An error occurred (ResourceNotFoundException) when calling the DescribeCluster operation: No cluster found for name: arn:aws:eks:us-west-2:913xxx371:cluster/ignitecluster.

hmmm this is kinda dumb those cluster names exist..so what do I do now

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817

2 Answers2

5

So yeah those clusters I named don't actually exist. I discovered that via:

 aws eks list-clusters

ultimately however, I still feel strong because we people need to make a tool that can just update your config with all the clusters that exist instead of having you name them.

So to do this programmatically, it would be:

aws eks list-clusters | jq '.clusters[]' | while read c; do
  aws eks update-kubeconfig --name "$c"
done;
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0

In my case, I was working with two AWS environments. My ~/.aws/credentials were pointing to one and had to be changed to point to the correct account. Once you change the account details, you can verify the change by running the following commands:

eksctl get clusters

and then setting the kube-config using the command below after verifying the region.

aws eks --region your_aws_region update-kubeconfig --name your_eks_cluster
rslj
  • 330
  • 1
  • 3
  • 13