'k8s: How to list all deployments versions
In Kubernetes how can I list all deployments versions? Also, is there a tool to compare deployment versions between two clusters (ex: dev & staging)?
Main problem: we've multiple identical development clusters, but deployment versions are not the same, so I need a way to list all deployment versions from one cluster to be able to compare it to versions from another cluster.
Solution 1:[1]
To list all deployment versions
kubectl get deployment -o=jsonpath="{range .items[*]}{'\n'}{.metadata.name}{': '}{range .spec.template.spec.containers[*]}{.image},{end}{end}" | sort
To compare deployment versions between two different clusters/contexts
diff --width=140 --suppress-common-lines --side-by-side \
<(kubectl get deployment --context=[TODO] --namespace=[TODO] -o=jsonpath="{range .items[*]}{'\n'}{.metadata.name}{': '}{range .spec.template.spec.containers[*]}{.image},{end}{end}" | sort) \
<(kubectl get deployment --context=[TODO] --namespace=[TODO] -o=jsonpath="{range .items[*]}{'\n'}{.metadata.name}{': '}{range .spec.template.spec.containers[*]}{.image},{end}{end}" | sort)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mahmoud Samy |
