Deploying Django Todo Application on Kubernetes: A Step-by-Step Guide ๐
Day 33: Launching your Kubernetes Cluster with Deployment
Table of contents
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! ๐