Skip to content

Instantly share code, notes, and snippets.

@alces
Created September 5, 2024 08:51
Show Gist options
  • Save alces/a67090757398fd9d93d94ece11b925a0 to your computer and use it in GitHub Desktop.
Save alces/a67090757398fd9d93d94ece11b925a0 to your computer and use it in GitHub Desktop.
Upgrade a version of sidecar container image in all namespaces where it's used
for ns in $(kubectl get sts --all-namespaces | awk '{if ($2 == "zookeeper") {print $1}}'); do
if [ $(kubectl get sts zookeeper -n $ns -o json | jq '.spec.template.spec.containers[1].image') != null ]; then
kubectl patch sts zookeeper -n $ns \
-p '{"spec":{"template":{"spec": {"containers":[{"name": "jmx-exporter", "image":"bitnami/jmx-exporter:1.0.1"}]}}}}'
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment