Skip to content

Instantly share code, notes, and snippets.

@flavono123
Last active March 27, 2023 02:37
Show Gist options
  • Select an option

  • Save flavono123/fdf4cbfd063d93cd6f4ddc2e73ee69d0 to your computer and use it in GitHub Desktop.

Select an option

Save flavono123/fdf4cbfd063d93cd6f4ddc2e73ee69d0 to your computer and use it in GitHub Desktop.
kubectl: list deploy's revisions and pod template hashes(replicaset)
#!/usr/bin/env sh
k rollout history deploy <deploy> -oyaml |
yq '{
.metadata.annotations."deployment.kubernetes.io/revision": .spec.template.metadata.labels.pod-template-hash
} as $item ireduce ({}; . *+ $item)'
: '
example outputs
"224": 78fdddd54b
"225": db987d555
"226": 6986cb66f7
"227": 6ffc78f78d
"228": 6557f98f5f
"229": 5fdff45b9c
"230": 694d4fccf8
"231": 67d7946f49
"232": 575d6595c7
"233": 858c94d889
"234": 5cd554d97f
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment