0
0
Kubernetesdevops~20 mins

ReplicaSet definition in Kubernetes - Mini Project: Build & Apply

Choose your learning style9 modes available
ReplicaSet definition
📖 Scenario: You are managing a simple web application on Kubernetes. To keep your app running smoothly, you want to make sure there are always exactly 3 copies (pods) of your app running. This helps if one pod stops working, others keep serving users.
🎯 Goal: Create a Kubernetes ReplicaSet definition YAML that ensures 3 replicas of a pod running the nginx container. This ReplicaSet will keep your app available by automatically replacing pods if they fail.
📋 What You'll Learn
Create a ReplicaSet named nginx-replicaset
Set the number of replicas to 3
Use the label app: nginx for pods
Define a pod template with a container named nginx using the image nginx:latest
Expose container port 80
💡 Why This Matters
🌍 Real World
ReplicaSets are used in Kubernetes to keep a set number of pod copies running. This helps maintain application availability and reliability.
💼 Career
Understanding ReplicaSets is essential for Kubernetes administrators and DevOps engineers to manage application scaling and fault tolerance.
Progress0 / 4 steps
1
Create the basic ReplicaSet structure
Write the first lines of the ReplicaSet YAML with apiVersion: apps/v1, kind: ReplicaSet, and metadata with name: nginx-replicaset.
Kubernetes
Need a hint?

Start by defining the API version, kind, and metadata name exactly as shown.

2
Add the replicas count and selector
Add a spec section with replicas: 3 and a selector that matches pods with label app: nginx.
Kubernetes
Need a hint?

Under spec, set replicas to 3 and define selector.matchLabels.app as nginx.

3
Define the pod template with container details
Inside spec, add template with metadata.labels matching app: nginx. Under template.spec.containers, define a container named nginx using image nginx:latest and expose port 80.
Kubernetes
Need a hint?

Make sure pod labels match the selector labels exactly. Define container name, image, and port as specified.

4
Output the complete ReplicaSet YAML
Print the full ReplicaSet YAML to verify your definition.
Kubernetes
Need a hint?

Check your YAML matches the full ReplicaSet definition exactly.