Skip to content

Instantly share code, notes, and snippets.

@dragonde
Last active January 3, 2024 13:12
Show Gist options
  • Save dragonde/e94842a8c700cc8ff9a13b7b5af67756 to your computer and use it in GitHub Desktop.
Save dragonde/e94842a8c700cc8ff9a13b7b5af67756 to your computer and use it in GitHub Desktop.
Kubernetes List Containers

List all containers in ALL namespaces

kubectl get pods --all-namespaces -o jsonpath="{.items[].spec['initContainers', 'containers'][].image}" |
tr -s '[[:space:]]' '\n' |
sort |
uniq -c

kubectl get pods --all-namespaces -o json |
jq -r '.items[].spec | .initContainers[].image, .containers[].image' |
sort |
uniq -c

kubectl get pods --all-namespaces -o go-template --template="{{range .items}}{{range .spec.containers}}{{.image}} {{end}}{{end}}"

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