You are currently viewing Complete Guide to Deployment Rollout in Kubernetes

Complete Guide to Deployment Rollout in Kubernetes

Introduction

In Kubernetes, managing deployment rollouts is crucial for ensuring seamless updates to your applications while maintaining high availability. This tutorial will guide you through the process of deploying applications and efficiently managing rollouts using Kubernetes.

Prerequisites

Before you begin, ensure you have the following:

  • Basic knowledge of Kubernetes concepts
  • Access to a Kubernetes cluster
  • kubectl command-line tool installed

Key Concepts

Before diving into deployment rollout, let’s understand key concepts:

  1. Deployment: Kubernetes Deployment manages a set of replicated Pods, ensuring they are available and updated as needed.
  2. Rolling Update: A strategy for updating Pods in a Deployment one-by-one, ensuring there’s no downtime during the update process.
  3. Rollout: The process of deploying or updating a Kubernetes application.

Step 1: Create a Sample Deployment

Let’s start by creating a simple Nginx deployment to demonstrate rollout.

# nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80

Apply the deployment:

kubectl apply -f nginx-deployment.yaml

Step 2: Verify Deployment

Check the status of the deployment:

kubectl get deployments

You should see the nginx-deployment listed with 3 replicas.

Step 3: Perform a Rolling Update

Now, let’s update the Nginx image version.

kubectl set image deployment/nginx-deployment nginx=nginx:1.19.10

Kubernetes will perform a rolling update, replacing each Pod with the updated version while ensuring the desired number of replicas are maintained.

Step 4: Monitor Rollout Progress

Monitor the rollout status:

kubectl rollout status deployment/nginx-deployment

You’ll see the status of the rollout, indicating whether it’s in progress or completed.

Step 5: Rollback (Optional)

If needed, rollback to the previous version:

kubectl rollout undo deployment/nginx-deployment

This will revert the deployment to the previous version.

Conclusion

With these steps, you can confidently update your applications without downtime, ensuring a seamless user experience.

Leave a Reply