Skip to content

Instantly share code, notes, and snippets.

@mjaromi
Last active February 25, 2021 21:16
Show Gist options
  • Save mjaromi/514258f3d01316f25d693c184070a43c to your computer and use it in GitHub Desktop.
Save mjaromi/514258f3d01316f25d693c184070a43c to your computer and use it in GitHub Desktop.
The problem is that if you have only one definition of a cluster, context or user in the `~/.kube/config` file
and you delete one of them then `kubectl` will set deleted type to `null` instead of `[]`.
Then if you try to `update-kubeconfig` using aws cli command you will see an error:
* if `contexts: null`: Tried to insert into contexts,which is a <class 'NoneType'> not a <class 'list'>
* if `users: null`: Tried to insert into users,which is a <class 'NoneType'> not a <class 'list'>
* if `clusters: null`: 'NoneType' object is not iterable
Simple workaround for above cases is to replace all `null` with `[]` then run aws cli `update-kubeconfig` command, like this:
sed -i 's/: null/: []/g' ~/.kube/config && \
aws eks --region ${AWS_REGION} update-kubeconfig --name ${EKS_CLUSTER_NAME}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment