0
0
KubernetesConceptBeginner · 3 min read

What is Rolling Update in Kubernetes: Explanation and Example

A rolling update in Kubernetes is a way to update applications without downtime by gradually replacing old versions of pods with new ones. It updates pods one at a time or in small batches, ensuring the app stays available during the process.
⚙️

How It Works

Imagine you have a team of workers building a house. Instead of firing all workers at once and hiring new ones, you replace them one by one. This way, the work continues without stopping. Kubernetes rolling update works similarly by updating pods gradually.

When you start a rolling update, Kubernetes creates new pods with the updated version while slowly terminating the old pods. It waits for new pods to be ready before moving on. This keeps your application running smoothly without downtime.

💻

Example

This example shows how to perform a rolling update on a deployment named my-app by changing the container image version.

bash
kubectl set image deployment/my-app my-app=my-app-image:v2
Output
deployment.apps/my-app image updated
🎯

When to Use

Use rolling updates when you want to update your application without stopping it. This is important for apps that need to be available 24/7, like websites or APIs. It helps avoid downtime and keeps users happy.

Rolling updates are also useful when you want to test new versions gradually and quickly roll back if something goes wrong.

Key Points

  • Rolling updates replace pods gradually to avoid downtime.
  • Kubernetes waits for new pods to be ready before deleting old ones.
  • You can update container images or configurations using rolling updates.
  • It supports quick rollback if the update causes issues.

Key Takeaways

Rolling update updates pods gradually to keep the app available.
It replaces old pods only after new pods are ready.
Use it to avoid downtime during app updates.
You can update container images without stopping the app.
Rolling updates support easy rollback on failure.