liveBook · Manning

Rolling update

As explained in Platform Engineering on Kubernetes

A rolling update replaces running application instances incrementally by starting updated instances and terminating older ones after the replacements are ready.

A rolling update replaces application Pods incrementally, upgrading them one at a time to minimize user downtime. Kubernetes Deployments coordinate the update while maintaining the requested replica count. section 2.3.1 section 2.3.2

A Deployment uses RollingUpdate by default. Its configuration can limit unavailable replicas and allow additional replicas during the update; readiness and liveness probes provide health signals for container availability and process status. section 2.3.1 section 2.3.2

A rolling update is triggered when the Deployment Pod template changes:

  • Kubernetes creates or updates ReplicaSets under the Deployment and progressively replaces Pods using the new specification. section 2.3.3
  • Changing a setting inside spec.template.spec, such as an environment variable, starts the rolling update mechanism. section 2.3.3
  • The alternative Recreate strategy stops all existing Pods before creating replacements, unlike the incremental RollingUpdate strategy. section 2.3.2

Updating the Conference Frontend

Scale the Frontend Deployment to two replicas with kubectl scale --replicas=2 deployments/conference-frontend-deployment, then enable FEATURE_DEBUG_ENABLED with kubectl set env deployment/conference-frontend-deployment FEATURE_DEBUG_ENABLED=true. Kubernetes creates a new ReplicaSet and progressively updates the Frontend Pods; refreshing the application can show responses from different replicas. section 2.3.3

Listing 2.3 Describing a deployment to see its details
> kubectl describe deploy conference-frontend-deployment 
Name:                   conference-frontend-deployment
Namespace:              default
CreationTimestamp:      Tue, 27 Jun 2023 08:21:21 +0100
Labels:                 app.kubernetes.io/managed-by=Helm
Annotations:            deployment.kubernetes.io/revision: 1
                        meta.helm.sh/release-name: conference
                        meta.helm.sh/release-namespace: default
Selector:               app=frontend
Replicas:               1 desired | 1 updated | 1 total | 1 available   #1
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=frontend
  Containers:
   frontend:
    Image:      salaboy/frontend-go...                                  #2
    Port:       8080/TCP
    Host Port:  0/TCP
    ...
    ...
    Environment:                                                        #3
      AGENDA_SERVICE_URL:         agenda-service.default.svc.cluster.local
      C4P_SERVICE_URL:            c4p-service.default.svc.cluster.local
      NOTIFICATIONS_SERVICE_URL:  notifications-service.default.svc.cluster.local
      KAFKA_URL:                  conference-kafka.default.svc.cluster.local
      POD_NODENAME:                (v1:spec.nodeName)
      POD_NAME:                    (v1:metadata.name)
      POD_NAMESPACE:               (v1:metadata.namespace)
      POD_IP:                      (v1:status.podIP)
      POD_SERVICE_ACCOUNT:         (v1:spec.serviceAccountName)
    Mounts:                       <none>
  Volumes:                        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   conference-frontend-deployment-<ID> (1/1 replicas created)
Events:                                                                 #4
  Type    Reason             Age   From                   Message
  ----    ------             ----  ----                   -------
  Normal  ScalingReplicaSet  48m   deployment-controller  Scaled up replica set conference-frontend-deployment-59d988899 to 1

Inspect StrategyType, replica counts, max unavailable, max surge, and the Pod template with kubectl describe deploy. section 2.3.2

How Platform Engineering on Kubernetes covers it

How deep it goes
Explains strategy defaults, replica limits, health probes, ReplicaSets, triggers, and inspection, but not detailed rollout commands or rollback procedures.
Examples
Demonstrates a Conference Frontend scaling change, environment-variable update, ReplicaSet creation, and responses from different replicas.
What it assumes
Assumes familiarity with Kubernetes Deployments and Pods while establishing replicas, health probes, ReplicaSets, and update strategies.
What you can do after
Operate/configure rolling updates with kubectl, change Deployment templates, and inspect rollout strategy and replica status.
How it connects
Connects Kubernetes Deployment, Pod, ReplicaSet, readiness probe, liveness probe, scaling, and rollback.

Also explained in

Compare how 8 books explain rolling update →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Platform Engineering on Kubernetes. The section links point to the parts of the book it draws on.