Skip to content

Instantly share code, notes, and snippets.

@ghousemohamed
Last active February 7, 2024 20:24
Show Gist options
  • Save ghousemohamed/f1d4254f38f6598aa50ef061dfdbde61 to your computer and use it in GitHub Desktop.
Save ghousemohamed/f1d4254f38f6598aa50ef061dfdbde61 to your computer and use it in GitHub Desktop.
Throwaway scripts
  1. Get all the images that are deployed in the k8s system:
kubectl get pods --all-namespaces -o=jsonpath="{range .items[*]}{'\n'}{.metadata.namespace}:{.metadata.name}{'\n'}{'\t'}{range .spec.containers[*]}{.name}:{.image}{'\n'}{end}{end}"

We can grep for the private registry to filter all the images we are managing from our end, and migrate them easily to the new system.

  1. Get all pods belonging to a particular nodegroup
kubectl get pods --selector=nodegroup=my-node-group # this does not work for some reason

I ended up doing

kubectl get nodes --l=eks.amazonaws.com/nodegroup=nodegroupname | grep default

To get all the containers running in the default namespace. I think this should be possible from the kubectl CLI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment