EKS update config with awscli command "aws eks update-kubeconfig" fails with error "'NoneType' object is not iterable"
Asked Answered
K

4

10

When running following command to update kubernetes config to get connected with EKS cluster then getting this error "'NoneType' object is not iterable"

aws eks update-kubeconfig --region us-east-2 --name <cluster name>
Kutz answered 9/5, 2022 at 18:33 Comment(1)
Could you post the output of the command with --debug please?Bering
I
20

Do you have an existing k8s config? Running

aws eks update-kubeconfig --region <region> --name <cluster name>

Generates a ~/.kube/config.

If you already have a ~/.kube/config, there could be a conflict between the file to be generated, and the file that already exists that prevents them from being merged.

If you have a ~/.kube/config file, and you aren't actively using it, running

rm ~/.kube/config

and then attempting

aws eks update-kubeconfig --region us-east-2 --name <cluster name>

afterwards will likely solve your issue.

If you are using your ~/.kube/config file, rename it something else so you could use it later, and then run the eks command again.

See a similar issue here: https://github.com/aws/aws-cli/issues/4843

Intervale answered 9/5, 2022 at 19:2 Comment(1)
Thankyou for point this out as there was existing config file that seems to be causing this issue... Once I removed & ran the command then it works fine.... Thanks a lot....Kutz
D
1

Might be null value set as following so you are getting this error:-

apiVersion: v1
clusters: null
contexts: null
current-context: ""
kind: Config
preferences: {}
users: null

run > $HOME/.kube/config will empty exist .kube/config file and then run again following cmd

aws eks update-kubeconfig --region us-east-2 --name <cluster name>

Desma answered 29/11, 2022 at 10:40 Comment(0)
S
0
  1. Run: kubectl config get-contexts.

  2. If you see your cluster, run: kubectl config use-context <cluster_name>.

  3. If you see your cluster, run: cat ~/.kube/config

  4. if you see something like:

apiVersion: v1 clusters: null contexts: null current-context: "" kind: Config preferences: {} users: null

Run: rm ~/.kube/config. It deletes your ~/.kube/config.

  1. Then run: aws eks update-kubeconfig --name <cluster_name> --region <cluster_region>. It creates ~/.kube/config.

  2. Run kubectl config current-context to see your context. End.

!!! Be sure you are in the right account: aws sts get-caller-identity.

Squab answered 9/2 at 23:29 Comment(0)
C
0

This "not iterable" error has happened to me before when I was in a sub-account of a main account. Switching your aws identity to the parent account made the "not iterable" error go away, so the command could complete properly.

Clareta answered 17/5 at 0:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.