best way to seed new machine with k8s/eks info

6/27/2019

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
aws-eks
eksctl
kubectl
kubernetes

1 Answer

6/27/2019

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
Source: StackOverflow