Day 32 Task: Launching your Kubernetes Cluster with Deployment

Day 32 Task: Launching your Kubernetes Cluster with Deployment

·

2 min read

Congratulations! on your learning on K8s on Day 31

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.

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" feature

  • apply the deployment to your k8s (minikube) cluster by command kubectl apply -f deployment.yml

Step 1:- To create a deployment file we need to clone the repository of sample todo-app so let's clone the repository of django-todo-app

git clone <repository URL>

Step 2:- After that build the django-todo-app using this command

docker build . -t nsparthu/django-todo:latest

Step 3:- Now push to docker hub

docker push <docker hub username>/django-todo:latest

Step 4:- Let's create a deployment for the django-todo-app vim deployment.yaml

apiVersion: apps/v1

kind: Deployment

metadata:

  labels:

    app: todo-app

spec:

  replicas: 3

  selector:

    matchLabels:

      app: todo-app

  template:

    metadata:

      labels:

        app: todo-app

    spec:

      containers:

      - name: todo-app

        image: nsparthu/django-todo

        ports:

        - containerPort: 8000

Step 4:- Use this command to apply for deployment.yaml file

kubectl apply -f deployment.yaml

This command will read the deployment configuration from the file and create the necessary resources on your Kubernetes cluster. Wait for the deployment to be successfully applied ⬆️

Step 5:- To verify that the deployment is running correctly, use the following command to get the status of the deployment:

kubectl get deployment

Step 6:- Check the status of the pods created by the deployment using the following command:

kubectl get pods

Congratulations you have successfully launched your Kubernetes cluster using Minikube and deploying a django-todo-app with auto-healing and auto-scaling features.


Happy Learning

Thanks For Reading! :)

-Sriparthu💝💥