Deploying Django Todo Application on Kubernetes: A Step-by-Step Guide ๐Ÿš€

Deploying Django Todo Application on Kubernetes: A Step-by-Step Guide ๐Ÿš€

Day 33: Launching your Kubernetes Cluster with Deployment

ยท

2 min read

Introduction

Welcome to this exciting tutorial where we embark on a journey to deploy a Django Todo application on Kubernetes. Whether you're just starting with Kubernetes or looking to enhance your skills, this guide will provide you with a step-by-step process to set up a robust environment for your Django Todo app, complete with auto-scaling and auto-healing capabilities.

Kubernetes, the container orchestration powerhouse, offers more than just deployment. In this tutorial, we'll not only deploy our Django Todo app but also explore Kubernetes' auto-scaling and auto-healing features. These functionalities ensure your application is not only scalable to handle increased loads but also resilient to recover from unexpected failures.

Step 1: Clone the Git Repository

To kick off our journey, let's clone the Django Todo app Git repository to your local machine. ๐Ÿง‘โ€๐Ÿ’ป

git clone https://github.com/SandhyaDeotare26/django-todo-cicd.git

Step 2: Build Docker Image

Navigate to the project directory and build the Docker image, turning your Django Todo app into a containerized masterpiece. ๐Ÿณ

cd django-todo-cicd
docker build -t your-dockerhub-username/django-todo:latest .

Step 3: Push Docker Image to DockerHub

Push the image to DockerHub, making it accessible to Kubernetes for deployment. ๐Ÿšข

docker push your-dockerhub-username/django-todo:latest

Step 4: Create Deployment YAML

Define the deployment configuration, showcasing the auto-scaling prowess of Kubernetes. ๐Ÿš€

apiVersion: apps/v1
kind: Deployment
metadata:
  name: todo-deployment
  labels:
    app: todo-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: todo-app
  template:
    metadata:
      labels:
        app: todo-app
    spec:
      containers:
      - name: todo-app
        image: your-dockerhub-username/django-todo:latest
        ports:
        - containerPort: 8000

Step 5: Deploy the Application

Watch as Kubernetes scales your app with ease. ๐Ÿ”„

kubectl apply -f deployment.yml

Step 6: Check Pods

Ensure your pods are thriving in the Kubernetes ecosystem. ๐ŸŒ

kubectl get pods

Step 7: Create Service YAML

Define the service configuration to expose your app to the world. ๐ŸŒ

apiVersion: v1
kind: Service
metadata:
  name: todo-service
spec:
  type: NodePort
  selector:
    app: todo-app
  ports:
    - port: 80
      targetPort: 8000
      nodePort: 30007

Step 8: Apply the Service Configuration

Expose your Django Todo app for the world to see. ๐ŸŒ

kubectl apply -f service.yml

Step 9: Check Service

Ensure your service is up and running. ๐Ÿš€

kubectl get svc

Step 10: Test the Application

Open your browser and experience the magic at your-kubernetes-node-ip:30007.

Conclusion

Congratulations, you've successfully deployed a Django Todo app on Kubernetes, unlocking the full potential of auto-scaling and auto-healing features. ๐ŸŽ‰ As you continue your Kubernetes journey, feel free to explore further and customize your application based on your evolving needs.

Happy Learning! ๐Ÿš€

ย