
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
- We have already installed and configured the 2 Node cluster in our demo environment.
- Please check the URL https://blog.assistanz.com/steps-to-install-kubernetes-cluster-manually-using-centos-7/ for more information
REPLICATION CONTROLLER CREATION
- Log in to the kubernetes master server through putty.

- Create a YAML file using the default editor.

- 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

- 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

- Command executed successfully.

- All the PODs will be in creating status.

- After few seconds, all the PODs are in running status.

VERIFYING REPLICATION CONTROLLER
- Use the below command to view the list of replication controllers.
kubectl get rc

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


DELETING THE REPLICATION POD
- Currently, there are four POD’s available in our demo replication controller.

- Let’s delete a POD and see how kubernetes reacts.

- 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.

- After few seconds, the new POD is in running status and replaced the old one.


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.
