Skip to content
Latchkey

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=120s

Gotchas

  • 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

Run this faster and cheaper on Latchkey managed runners. Start free →