Kahibaro
Discord Login Register

Rolling updates and rollbacks

Why rolling updates matter

Rolling updates let you deploy new versions of your application without stopping service. Instead of replacing all pods at once, OpenShift gradually replaces old pods with new ones, keeping the application available.

Rollbacks are the counterpart: if something goes wrong with a new version, you quickly return to a previously working state.

In OpenShift, rolling behavior is implemented by:

Both support rolling updates and rollbacks, but the mechanisms and knobs differ slightly.

This chapter focuses on:

Rolling updates with Deployments

A Deployment manages a ReplicaSet, which in turn manages pods. During a rolling update:

  1. A new ReplicaSet is created for the new version.
  2. Pods from the new ReplicaSet are gradually scaled up.
  3. Pods from the old ReplicaSet are gradually scaled down.
  4. Service traffic is continuously routed to all ready pods (old + new) via the underlying Service.

You control the rollout strategy via the spec.strategy field of the Deployment.

RollingUpdate strategy

For a rolling update, spec.strategy.type is RollingUpdate (the default):

yaml
spec:
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%

Key parameters:

Example:

During the rollout:

Choosing values is a trade-off between:

Deployment update triggers

Deployments create new revisions when certain fields change, most commonly:

A typical update workflow:

  1. Edit the Deployment (YAML, oc set image, or via the web console).
  2. A new ReplicaSet is created.
  3. Rolling update starts according to the configured strategy.

Example using oc:

bash
oc set image deployment/myapp mycontainer=image-registry.example.com/team/myapp:v2

This triggers a new revision of the Deployment and starts a rolling update.

Controlling progress and timeouts

Deployments track rollout progress:

Example:

yaml
spec:
  progressDeadlineSeconds: 600  # 10 minutes

If pods fail readiness checks or cannot be scheduled, the Deployment will not complete, and you’ll see conditions like ProgressDeadlineExceeded.

OpenShift commands to inspect:

bash
oc rollout status deployment/myapp
oc describe deployment/myapp

Rolling updates with DeploymentConfigs

DeploymentConfig is an OpenShift-specific controller with its own rolling strategy and trigger system. It behaves similarly to a Deployment but uses ReplicationController objects instead of ReplicaSet.

Rolling strategy in DeploymentConfig

The rolling strategy is defined under spec.strategy.type: Rolling:

yaml
spec:
  strategy:
    type: Rolling
    rollingParams:
      maxUnavailable: 25%
      maxSurge: 25%
      intervalSeconds: 1
      timeoutSeconds: 600
      updatePeriodSeconds: 1

Important parameters:

You can also configure pre/post lifecycle hooks in rollingParams (e.g., to run migrations before switching fully to new pods), but hook details are typically treated in more advanced chapters.

DeploymentConfig triggers and image changes

DeploymentConfig supports triggers to start new deployments automatically:

Typical triggers:

Example snippet:

yaml
spec:
  triggers:
    - type: ConfigChange
    - type: ImageChange
      imageChangeParams:
        automatic: true
        containerNames:
          - mycontainer
        from:
          kind: ImageStreamTag
          name: myapp:latest

Whenever the ImageStreamTag myapp:latest is updated, a new rollout is initiated.

`oc` commands for DeploymentConfigs

Key commands:

bash
  oc rollout latest dc/myapp
bash
  oc rollout status dc/myapp

The rollout behavior is still governed by rollingParams even if the rollout is manual.

Monitoring and managing rollouts

Regardless of whether you use Deployment or DeploymentConfig, you need to:

Inspecting rollout status

For Deployments:

bash
oc rollout status deployment/myapp
oc get deployment myapp
oc describe deployment myapp

For DeploymentConfigs:

bash
oc rollout status dc/myapp
oc get dc myapp
oc describe dc myapp

Typical things to look for:

Pausing and resuming rollouts (Deployments only)

Deployments support pausing:

bash
oc rollout pause deployment/myapp
# modify spec.template, e.g., add environment variables, sidecars, etc.
oc rollout resume deployment/myapp

While paused, changes to the deployment specification are recorded but not applied to pods until you resume. This is useful for batching multiple changes into a single rollout.

Rollbacks: reverting to a previous version

If a new version misbehaves (errors, performance issues, failed health checks), you can roll back.

The core idea:

Rollbacks with Deployments

To view revisions and history:

bash
oc rollout history deployment/myapp
oc rollout history deployment/myapp --revision=3

To roll back to the previous revision:

bash
oc rollout undo deployment/myapp

To roll back to a specific revision:

bash
oc rollout undo deployment/myapp --to-revision=3

Outcome:

Note:

Rollbacks with DeploymentConfigs

DeploymentConfigs have a similar concept, with an internal version number.

View rollout history:

bash
oc rollout history dc/myapp
oc rollout history dc/myapp --revision=3

Rollback:

bash
oc rollout undo dc/myapp
# or to a specific revision:
oc rollout undo dc/myapp --to-revision=3

You can also manually set spec.template from a previous revision if you need finer control, but oc rollout undo is usually sufficient.

What gets reverted (and what doesn’t)

Rollbacks typically revert:

They do not revert:

This means a “rollback” in OpenShift is a workload configuration rollback, not a full environment time machine.

Dealing with failed rollouts

During a rollout, failures can occur due to:

Detecting failures

Use:

bash
oc rollout status deployment/myapp
oc logs deployment/myapp
oc describe pod <pod-name>

or for DeploymentConfigs:

bash
oc rollout status dc/myapp
oc logs dc/myapp
oc describe pod <pod-name>

Signs of a failed rollout:

Reacting to failures

Common responses:

Zero-downtime and readiness considerations

Rolling updates depend heavily on pods becoming ready before they are counted toward available capacity.

Key aspects:

Tuning readiness and termination behavior is essential for true zero-downtime rolling updates.

Blue-green and canary as alternatives

Rolling updates are not the only strategy:

OpenShift’s rolling update feature can be combined with these patterns (for example, by using multiple Deployments and Routes), but the implementation details of blue-green and canary are typically addressed in more advanced deployment chapters.

Best practices for rolling updates and rollbacks

Using rolling updates and rollbacks correctly lets you ship changes frequently while maintaining stability and user experience—one of the core advantages of OpenShift-based application deployment.

Views: 12

Comments

Please login to add a comment.

Don't have an account? Register now!