Sobes.tech
Junior — Middle

Explain the principle of the zero-downtime update method known as Rolling Update.

sobes.tech AI

Answer from AI

Rolling Update is a method of updating an application or service without stopping the entire system. The main idea is to gradually replace old versions of components with new ones to ensure continuous operation.

How it works:

  • The update occurs in stages, for example, one service instance at a time.
  • A new instance is launched with the updated version.
  • After successful launch and verification, the new instance starts receiving traffic.
  • The old instance is gradually shut down.
  • The process repeats for all instances until the update is complete.

Advantages:

  • Minimizes downtime.
  • Allows rollback if the new version works incorrectly.
  • Smooth transition without abrupt changes for users.

Example in Kubernetes:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
  template:
    spec:
      containers:
      - name: app-container
        image: my-app:v2

Here, maxUnavailable: 1 means no more than one pod can be unavailable during the update, and maxSurge: 1 indicates that one additional pod can be created above the desired number for a smooth update.