How to properly do a rollout restart? Follow these simple steps for updating your app smoothly and fast.

How to properly do a rollout restart? Follow these simple steps for updating your app smoothly and fast.

Understanding Rollout Restart

A rollout restart is a mechanism, primarily within Kubernetes, used to trigger a new deployment rollout for a workload (like a Deployment, StatefulSet, or DaemonSet) without changing its underlying template or configuration. Essentially, it forces all existing pods managed by the controller to be gracefully terminated and replaced with new ones, following the defined update strategy (e.g., RollingUpdate).

Why Use Rollout Restart?

There are several scenarios where a rollout restart is beneficial:

  • Configuration Refresh: When configuration changes are managed outside the pod spec (e.g., in ConfigMaps or Secrets that are mounted as volumes but not directly referenced in the pod template in a way that triggers an automatic rollout). A restart ensures pods pick up the latest configuration.
  • Dependency Updates: If your application relies on external services or data that has been updated, restarting pods can force them to re-initialize connections or re-fetch data.
  • Clearing Bad State: In some cases, application instances might get into a stuck or erroneous state that can be resolved by a fresh start.
  • Applying Security Patches: If a base image has been updated with security patches, and your deployment uses a tag like `latest` or a specific version that has been rebuilt, a rollout restart ensures new pods are created from the updated image, even if the image tag in the deployment spec hasn't changed.
  • Periodic Refresh: For applications that might have memory leaks or other cumulative issues over long uptimes, a scheduled rollout restart can act as a proactive measure.

How to Perform a Rollout Restart

In Kubernetes, the most common way to initiate a rollout restart is using the kubectl command-line tool:

How to properly do a rollout restart? Follow these simple steps for updating your app smoothly and fast.

kubectl rollout restart <resource_type>/<resource_name> [flags]

For example, to restart a Deployment named "my-app":

kubectl rollout restart deployment/my-app

You can also target other workloads:

  • kubectl rollout restart statefulset/my-db
  • kubectl rollout restart daemonset/my-agent

This command works by annotating the pod template within the workload's specification (specifically, */restartedAt is set to the current time). This change to the pod template triggers the controller's standard rolling update logic.

How to properly do a rollout restart? Follow these simple steps for updating your app smoothly and fast.

Impact and Considerations

Performing a rollout restart initiates a controlled, rolling update:

  • Zero Downtime (Ideally): If your deployment strategy (e.g., RollingUpdate with appropriate `maxUnavailable` and `maxSurge` settings) and readiness/liveness probes are correctly configured, the restart should happen with minimal to no user-perceptible downtime.
  • Resource Consumption: During the rollout, there will be a temporary increase in resource consumption as new pods are started before old ones are fully terminated (depending on `maxSurge`).
  • Pod Disruption Budgets (PDBs): PDBs will be respected, potentially slowing down the restart if the budget is restrictive.
  • Not a Configuration Change Fix: It's important to remember that `rollout restart` itself doesn't fix underlying configuration errors in your deployment spec. It only forces a re-deployment with the current spec. If the spec references an incorrect image or bad configuration, the new pods will also inherit these issues.

A rollout restart is a valuable operational tool for maintaining the health and up-to-dateness of applications running in dynamic environments like Kubernetes.

Share this article: