Created
October 3, 2025 00:15
-
-
Save mikerochip/ef10bcd77869a3d7403752ff83d5a0e9 to your computer and use it in GitHub Desktop.
Restart Kube Deployments in all namespaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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