Skip to content

Instantly share code, notes, and snippets.

@besteban1989
Last active March 19, 2024 16:08
Show Gist options
  • Save besteban1989/f1cdc09a5442948f6430938eff9f5501 to your computer and use it in GitHub Desktop.
Save besteban1989/f1cdc09a5442948f6430938eff9f5501 to your computer and use it in GitHub Desktop.
Get the current docker images used in pod/deployments
# To get the images from deployments
kubectl get deploy -n YOUR_NAMESPACE -o jsonpath="{.items[*].spec.template.spec.containers[*].image}" |\
tr -s '[[:space:]]' '\n'
# To get the images from pods (it can be duplicates, needs to be removed with commands)
kubectl get pods -n YOUR_NAMESPACE -o jsonpath="{.items[*].spec.containers[*].image}" |\
tr -s '[[:space:]]' '\n' |\
sort |\
uniq -c
# Get pod names and the node that hosts
kubectl get pods -o=custom-columns=NAME:.metadata.name,NODE:.spec.nodeName
# Get current replicas and limits for deployments
kubectl get deploy -o=custom-columns=NAME:.metadata.name,REPLICAS:.spec.replicas,MEMORYREQUEST:".spec.template.spec.containers[*].resources.requests.memory",MEMORYLIMIT:".spec.template.spec.containers[*].resources.limits.memory",CPUREQUEST:".spec.template.spec.containers[*].resources.requests.cpu",CPULIMITS:".spec.template.spec.containers[*].resources.limits.cpu"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment