Deploy Replica Set in Kubernetes Cluster

Deploy Replica Set in Kubernetes Cluster

How to Set Up a Replica Set in a Kubernetes Cluster

Table of contents

Tasks

  • Create a ReplicaSet using the nginx image with the latest tag (specify as nginx:latest) and name it nginx-replicaset.

  • Apply labels: app as nginx_app, type as front-end.

  • Name the container nginx-container. Ensure the replica count is 4.

Steps

  1. Create a manifest file name it as replicaset.yaml.

     apiVersion: apps/v1
     kind: ReplicaSet
     metadata:
       name: nginx-replicaset
     spec:
       replicas: 4
       selector:
         matchLabels:
           app: nginx_app
           type: front-end
       template:
         metadata:
           labels:
             app: nginx_app
             type: front-end
         spec:
           containers:
           - name: nginx-container
             image: nginx:latest
    

  2. Now apply the configuration in k8s cluster.

     kubectl apply -f replicaset.yaml
    

  3. Get replicaset

     kubectl get replicaset
    

  4. Check the description of this replicaset.

     kubectl describe replicaset nginx-replicaset
    

    #k8s #kubernetes #replicaset