Day 32 Task: Launching your Kubernetes Cluster with Deployment

Congratulation ! on your learning on K8s on Day-31

What is Deployment in k8s?

A deployment is an object in Kubernetes that helps you to manage a group of identical pods.

Without a deployment, you’d got to produce, update, and delete a bunch of pods manually.

With a deployment, we tend to declare one object in a very YAML file.

Using Kubernetes deployment we can autoscale the applications very easily.

Example:-

Today's task let's keep it very simple.

Task-1:

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

Add a deployment.yml file

This deployment file will create a deployment with 3 replicas of a container named Django-todo. The container is based on the image rohit1627/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 django-todo, which is used in the selector to identify the pods that belong to the deployment.

Apply the deployment to your k8s (kubeadm) cluster.

kubectl apply -f deployment.yaml

To list a deployment:

kubectl get deployments

To list pods:

here deployment file creates 3 replicas of a container

Use Case

The following are typical use cases for Deployments in a Kubernetes cluster are :

  • We can create a Deployment to roll out a ReplicaSet. The ReplicaSet creates Pods within the background. We can check the status of the current deployment rollout was completed or not.

  • Declare the new state of the Pods by changing the PodTemplateSpec of the deployment. A brand new ReplicaSet is made and also the Deployment manages to move the Pods from the previous ReplicaSet to the new one at a controlled rate.
    Rollback to an earlier Deployment revision if the present state of the deployment isn’t stable. every rollback updates the revision of the deployment in the K8s cluster.

  • Scale up the Deployment to facilitate more load. we can scale up the deployment during hours when we see huge traffic and network in/outs

  • We can Pause the Deployment to update/apply fixes and bugs to its pod spec and then can start a new rollout for changes to reflect

Thank you for reading!! I hope you find this article helpful......