Launching Kubernetes Cluster with Deployment (Part-3)
Launching Kubernetes Cluster with Deployment (Part-3)
Deployment in K8s
A Deployment is a high-level resource that provides declarative updates for managing a set of identical replicas of a pod. A pod is the smallest deployable unit in Kubernetes that represents a single instance of a containerized application.
Deployments use a rolling update strategy by default, which ensures that new replicas are gradually introduced and old replicas are gracefully terminated. This strategy helps to minimize downtime and ensure that the application remains available during the update process.
Task-1:
Create one Deployment file to deploy a sample todo-app on K8s using the "Auto-healing" and "Auto-Scaling" feature; Will create deployment.yml file where we update replica as "3"
Step 1 : First we can clone the code to our local machine with the following command
Step 2: Now the code has in our local machine then we have to create a docker file.
Step 3: Post image building, with docker run command will create a container.
Step 4 : Even we can check with Curl command if application working fine or not, with curl we can initialized the request and ensure that the app is running or not, We can get below output over here so everything is fine.
Step 5: To send an image to docker hub we can use docker login command from our local machine to push image in hub & then image will transfer in docker hub.
To release the port '8000' we have to kill docker container first with docker kill <container Id>.
Step 6: Below is the deployment.yaml file which we have created.
Step 7 : Once we have done with deployment.yml file we have facing below error. Then we can start the minikube with "minikube start" command.
apply the deployment to k8s cluster by command kubectl apply -f deployment.yml
Step 8: We can check over here 3 pods are in running state (As we have mentioned 3 replica in YAML file) we can see 3 pod's created; this is for the Autoscaling
Step 9: We can check our deployment with "kubectl get deployments" command.
Step 10 : We have deleted the pods with command "kubectl delete pods "
Step 11: We can see once we deleted the pod, immediately K8 cluster has created the pod within a second & this is the "Auto-Healing"
Thank You !!
Happy Learning!!