Day - 32 : Launching your Kubernetes Cluster with Deployment

Day - 32 : Launching your Kubernetes Cluster with Deployment

What is Deployment in k8s

A Deployment provides a configuration for updates for Pods and ReplicaSets.

You describe a desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate. You can define Deployments to create new replicas for scaling, or to remove existing Deployments and adopt all their resources with new Deployments.

Tasks:

Create one Deployment file to deploy a sample todo-app on K8s using "Auto-healing" and "Auto-Scaling" feature

Now Clone the repository from GitHub. Github Repo link: https://github.com/sahilk30/django-todo-cicd.git

Now let's create a Dockerfile.

Now let's build the image.

docker build . -t django-todo:latest

Now let's create a docker container for checking whether the image is running on port or not.

docker run -d -p 8000:8000 django-todo:latest

Now we will push the docker image to the docker hub.

docker login
docker push kamble3sahil/django-todo:latest

Add a deployment.yml file

This deployment file will create a deployment with 2 replicas of a container named todo. The container is based on the image kamble3sahil/django-todo:latest, which should be replaced with the actual image name of your application. The container listens on port 8000. The deployment is associated with a label app: todo, which is used in the selector to identify the pods that belong to the deployment.

Apply the deployment to your k8s (minikube) cluster

kubectl apply -f deployment.yaml

To list a deployment:

kubectl get deployments

To get Pods :

kubectl get pods

Now lets try to delete a pod and lets see whether it creates a new pod

kubectl delete pod <pod_name>

As you can see pod has been created concept called as Auto healing

Auto-scaling is a feature that allows Kubernetes automatically scale the number of pods a deployment based on the resource usage of the existing pods.

Did you find this article valuable?

Support Sahil Kamble's blog by becoming a sponsor. Any amount is appreciated!