Day 88: Project 9- Efficient Deployment of a Django Todo App on AWS EC2 with Kubernetes: Harnessing Auto-Scaling and Auto-Healing
Project Overview: The project entails deploying a Django Todo app on AWS EC2 using a Kubernetes cluster provisioned with Kubeadm. Kubernetes facilitates auto-scaling and auto-healing of the application, ensuring reliability and scalability.
Task-01: Kubernetes Cluster Setup on AWS EC2:
Launch an EC2 instance on AWS.
Set up a Kubernetes cluster using Kubeadm following the provided guide.
https://github.com/LondheShubham153/kubestarter/blob/main/kubeadm_installation.md
Verify connectivity between worker and master nodes.
Deployment and Service Configuration:
Clone the django-todo-cicd repository from GitHub.
git clone https://github.com/VedThavkar/django-todo-cicd
Build and run Docker images for the Django Todo app.
docker build -t vedant/django-todo . docker run -d -p vedant/django-todo
Push Docker images to Docker Hub.
docker push vedantthavkar/django-todo:latest
Create deployment and service YAML files for Kubernetes configuration.
Deployment YAML (deployment.yml):
apiVersion: apps/v1
kind: Deployment
metadata:
name: todo-deployment
labels:
app: todo-app
spec:
replicas: 2
selector:
matchLabels:
app: todo-app
template:
metadata:
labels:
app: todo-app
spec:
containers:
- name: todo-app
image: vedanthavkar/django-todo
ports:
- containerPort: 8000
Service YAML (service.yml):
apiVersion: v1
kind: Service
metadata:
name: todo-service
spec:
type: NodePort
selector:
app: todo-app
ports:
- name: http
port: 80
targetPort: 8000
nodePort: 30007
Deployment and Verification:
Apply the deployment and service YAML files using
kubectl apply
.kubectl apply -f deployment.yml kubectl apply -f service.yml
Verify that pods are running successfully.
Accessing the Application: Access the Django Todo app via the worker node's public IP: http://<Public-ip-address>:30007/todos/
Conclusion: This project demonstrates the efficient deployment of a Django Todo application on AWS EC2 using Kubernetes. Kubernetes provides robust container orchestration, enabling auto-scaling and auto-healing for enhanced application reliability and scalability.
Key Highlights:
Kubernetes Cluster Setup: Establishing a Kubernetes cluster on AWS EC2.
Docker Image Management: Building and pushing Docker images for the application.
Kubernetes Deployment and Service Configuration: Defining deployment and service YAML files for Kubernetes.
Verification and Validation: Ensuring correct application deployment and functionality.
Practical Application: Showcase of cloud-native technologies for efficient application hosting and management.
This project serves as a valuable resource for understanding cloud-native deployment practices and Kubernetes orchestration. It underscores the importance of modern DevOps practices in ensuring scalable and reliable application deployment.
As you delve deeper into cloud and DevOps, this project equips you with essential skills for deploying and managing applications in cloud-native environments. Incorporate these learnings into your portfolio and continue exploring the vast landscape of cloud technologies.
Happy learning, and may your future endeavors be as successful as this deployment!