Saturday, 4 October 2025

Create a ReplicaSet in Kubernetes Using httpd:latest (4 Replicas)

 Our course you can check :-   Udemy course 


Ques:-

The DevOps team is gearing up to deploy applications on a Kubernetes cluster for migration purposes. A team member has been tasked with creating a ReplicaSet outlined below:

Create a ReplicaSet using httpd image with latest tag (ensure to specify as httpd:latest) and name it httpd-replicaset.

Apply labels: app as httpd_app, type as front-end.

Name the container httpd-container. Ensure the replica count is 4.


Ans:-


raj@jumphost ~$ vi rs.yaml

raj@jumphost ~$ ls

rs.yaml

raj@jumphost ~$ cat rs.yaml 

apiVersion: apps/v1

kind: ReplicaSet

metadata:

  name: httpd-replicaset

  labels:

    app: httpd_app

    type: front-end

spec:

  replicas: 4

  selector:

    matchLabels:

      app: httpd_app

      type: front-end

  template:

    metadata:

      labels:

        app: httpd_app

        type: front-end

    spec:

      containers:

      - name: httpd-container

        image: httpd:latest

        ports:

        - containerPort: 80

raj@jumphost ~$ 

raj@jumphost ~$ kubectl apply -f rs.yaml

replicaset.apps/httpd-replicaset created

raj@jumphost ~$ 

raj@jumphost ~$ kubectl get rs 

NAME               DESIRED   CURRENT   READY   AGE

httpd-replicaset   4         4         4       13s

raj@jumphost ~$ 

raj@jumphost ~$ kubectl get pods

NAME                     READY   STATUS    RESTARTS   AGE

httpd-replicaset-5c875   1/1     Running   0          24s

httpd-replicaset-7l7sf   1/1     Running   0          24s

httpd-replicaset-9t5jh   1/1     Running   0          24s

httpd-replicaset-xkrlq   1/1     Running   0          24s

raj@jumphost ~$ 



No comments:

Post a Comment