0
0
Kubernetesdevops~30 mins

Recreate update strategy in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
Recreate Update Strategy in Kubernetes
📖 Scenario: You are managing a web application running on Kubernetes. You want to update the application pods so that the old pods are completely terminated before new pods start. This is important to avoid conflicts during the update.
🎯 Goal: Create a Kubernetes Deployment manifest that uses the Recreate update strategy, which terminates all old pods before creating new ones.
📋 What You'll Learn
Create a Deployment named webapp in the default namespace
Use the image nginx:1.21 for the pods
Set the update strategy to Recreate
Set the number of replicas to 2
Expose the pods on container port 80
💡 Why This Matters
🌍 Real World
Using the Recreate update strategy is useful when your application cannot run multiple versions simultaneously or when you want to avoid conflicts during updates.
💼 Career
Understanding update strategies in Kubernetes is essential for DevOps engineers to manage application deployments safely and reliably.
Progress0 / 4 steps
1
Create the basic Deployment manifest
Create a Kubernetes Deployment manifest named webapp with 2 replicas using the image nginx:1.21. Set the container port to 80. Do not add the update strategy yet.
Kubernetes
Need a hint?

Start by defining apiVersion, kind, metadata, and spec. Use replicas: 2 and set the container image to nginx:1.21. Don't add the update strategy yet.

2
Add the Recreate update strategy
Add the strategy field under spec and set its type to Recreate in the Deployment manifest.
Kubernetes
Need a hint?

Under spec, add strategy: and set type: Recreate to specify the update strategy.

3
Apply the Deployment manifest
Use the kubectl apply -f deployment.yaml command to create the Deployment in the cluster. Assume the manifest is saved as deployment.yaml.
Kubernetes
Need a hint?

Use kubectl apply -f deployment.yaml to create or update the Deployment from the YAML file.

4
Verify the update strategy
Run the command kubectl get deployment webapp -o jsonpath='{.spec.strategy.type}' to display the update strategy type of the webapp Deployment.
Kubernetes
Need a hint?

This command extracts the update strategy type from the Deployment's spec. It should print Recreate.