Terraform Replica Set Code

                TERRAFORM REPLICA SET




KUBERNETES - Kubernetes is an open-source container orchestration system that manages the PODs 24 X 7. It Automatically Deploys, Scales, and is fault-tolerant. 


REPLICA SET- Replica Set is used to make the replicas of PODs that are deleted. Replica Set uses Set Based Selector and Equality Based Selector. Replica Set is a New Version Of Replication Controller.


TASK -

  1. Make a service that keep eye on PODs.

  2. Terraform code for Replica Set



TERRAFORM CODE FOR SERVICE -


This Kubernetes Service is used to access the PODs’ work by the tag. The Port took is 80 so that it will be publically accessible.



TERRAFORM DEPLOYMENT CODE-


Terraform Deployment Resources not only deploys the POD but also make a replica set. The "replica" taken is 3 and "match_labels" is "Equality Based Selector".The Image taken from the link.



INITIALIZE TERRAFORM-


The command “terraform init” will initialize the terraform and download all the relevant plugins.



TERRAFORM APPLY-


The command “terraform apply -auto-approve ” will make the changes and create the POD and replica set without asking yes or no.



SEE PODs-


By the command “kubectl get pods” see the PODs are created or not. Here the PODs are created.



SEE REPLICASET-


By the command “kubectl get rs” see the replica set is created or not.



ACCESS THE PODS -


The command “ kubectl get pods -w -l test=MyApp” will access the PODs status when POD is created or terminated. This command will run when service is created. here “test=MyApp ” is the tag we gave to the POD.



TERRAFORM DEPLOYMENT- 


When the terraform code is deployed it gave the URL so that the public can see the website. Here minikube is used to see the service list as it makes it easy to run Kubernetes locally.



SEARCH BY URL -


Search the URL on the search engine and you will see the webpage.



DELETE PODs -


kubectl delete pods -allcommand will delete all the PODs but in the code, we have made replicas so that will create another pod.

So, check that again the pods are running or not write command “kubectl get pods” and to check replica set is created or not write command “kubectl get rs”.



SEE ALL THE PROCESS- 


The command “ kubectl get pods -w -l test=MyApp”  is showing the status of POD.



Github Link

There is no direct code available in Terraform for ReplicaSet So this is used.

Comments

Post a Comment

Popular posts from this blog

HOW GOOGLE USES MACHINE LEARNING ??

AWS CLOUDFRONT SETUP