How to Restart a Deployment From CI in GitHub Actions
kubectl rollout restart triggers a rolling replacement of every pod without changing the manifest, which reloads mounted ConfigMaps and Secrets.
Run kubectl rollout restart deployment/<name> to recreate pods gracefully, then wait for the rollout so the workflow only succeeds once the new pods are ready.
Steps
- Authenticate to the cluster in the job.
- Run
kubectl rollout restart deployment/<name>. - Wait with
kubectl rollout status --timeout.
Workflow
.github/workflows/restart.yml
on:
workflow_dispatch:
jobs:
restart:
runs-on: ubuntu-latest
steps:
- run: kubectl rollout restart deployment/web -n prod
- run: kubectl rollout status deployment/web -n prod --timeout=120sGotchas
- A restart respects the Deployment maxUnavailable/maxSurge, so it is a true rolling restart.
- Pods only reload a ConfigMap/Secret on restart unless you use a projected volume or a reloader controller.
Related guides
How to Scale a Deployment From CI in GitHub ActionsChange the replica count of a Kubernetes Deployment from GitHub Actions with kubectl scale, useful for schedu…
How to Create or Update a Kubernetes Secret From CI in GitHub ActionsCreate or update a Kubernetes Secret idempotently from GitHub Actions by piping kubectl create secret through…