Skip to content

Instantly share code, notes, and snippets.

@mikerochip
Created October 3, 2025 00:15
Show Gist options
  • Select an option

  • Save mikerochip/ef10bcd77869a3d7403752ff83d5a0e9 to your computer and use it in GitHub Desktop.

Select an option

Save mikerochip/ef10bcd77869a3d7403752ff83d5a0e9 to your computer and use it in GitHub Desktop.
Restart Kube Deployments in all namespaces
#!/bin/bash -e
if [ -z "$DEPLOYMENT" ]; then
read -rp "Deployment Name (set DEPLOYMENT to skip this): " DEPLOYMENT
if [ -z "$DEPLOYMENT" ]; then
echo "Missing DEPLOYMENT"
exit 1
fi
fi
Deploys=$(kubectl get deploy -A \
--field-selector "metadata.name==$DEPLOYMENT" \
-o custom-columns=NS:.metadata.namespace --no-headers)
echo "Deploys:"
echo "$Deploys"
for deploy in $Deploys; do
echo "Restarting $deploy..."
kubectl rollout restart deployment/$DEPLOYMENT -n $deploy
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment