Steps to create a Replication Controller using YAML

In this blog, We will show you the Steps to create a Replication Controller using YAML in Kubernetes Environment.

REQUIREMENTS

  • 2 Node Cluster ( 1 Master VM with 2 Nodes)
  • Kubernetes Components

INFRASTRUCTURE OVERVIEW

REPLICATION CONTROLLER CREATION

  • Log in to the kubernetes master server through putty.
Steps to create a Replication Controller using YAML
  • Create a YAML file using the default editor.
Steps to create a Replication Controller using YAML
  • Add the below coding and save it.

apiVersion: v1
kind: ReplicationController
metadata:
    name: rep-pod
spec:
    replicas: 4
    selector:
       app: web
       env: test
    template:
       metadata:
          labels:
             app: web
             env: test
       spec:
          containers:
          - name: rep-cont
            image: nginx

Steps to create a Replication Controller using YAML
  • Execute the below command to create a replication controller using YAML file.

Syntax: kubectl apply -f <filename with extension>

Example: kubectl apply -f rc.yml

Steps to create a Replication Controller using YAML
  • Command executed successfully.
Steps to create a Replication Controller using YAML
  • All the PODs will be in creating status.
Steps to create a Replication Controller using YAML
  • After few seconds, all the PODs are in running status.
Steps to create a Replication Controller using YAML

VERIFYING REPLICATION CONTROLLER

  • Use the below command to view the list of replication controllers.

kubectl get rc

Steps to create a Replication Controller using YAML

Note: rc is the short-hand of replication controller

  • Describe command will use to view the detailed information about the replication controller.

Syntax: kubectl describe rc <replication controller name>

Example: kubectl describe rc rep-pod

Steps to create a Replication Controller using YAML
Steps to create a Replication Controller using YAML

DELETING THE REPLICATION POD

  • Currently, there are four POD’s available in our demo replication controller.
Steps to create a Replication Controller using YAML
  • Let’s delete a POD and see how kubernetes reacts.
Steps to create a Replication Controller using YAML
  • Kubernetes will start creating a new POD automatically. Kubernetes will keep on checking the desired state. When the desired state fails, kubernetes takes own action to restore the state.
Steps to create a Replication Controller using YAML
  • After few seconds, the new POD is in running status and replaced the old one.
Steps to create a Replication Controller using YAML
Steps to create a Replication Controller using YAML

EXTERNAL LINKS

https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/

VIDEO

Thanks for reading this blog. We hope it was useful for you learn about creating a replication controller using YAML file in the kubernetes environment.

Loges

Leave a Reply

Your email address will not be published. Required fields are marked *