Day 88: Project 9- Efficient Deployment of a Django Todo App on AWS EC2 with Kubernetes: Harnessing Auto-Scaling and Auto-Healing

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:

  1. Launch an EC2 instance on AWS.

  2. Set up a Kubernetes cluster using Kubeadm following the provided guide.

    https://github.com/LondheShubham153/kubestarter/blob/main/kubeadm_installation.md

  3. Verify connectivity between worker and master nodes.

Deployment and Service Configuration:

  1. Clone the django-todo-cicd repository from GitHub.

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

  2. Build and run Docker images for the Django Todo app.

      docker build -t vedant/django-todo .
      docker run -d -p vedant/django-todo
    
  3. Push Docker images to Docker Hub.

      docker push vedantthavkar/django-todo:latest
    

  4. 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:

  1. Apply the deployment and service YAML files using kubectl apply.

      kubectl apply -f deployment.yml
      kubectl apply -f service.yml
    

  2. 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:

  1. Kubernetes Cluster Setup: Establishing a Kubernetes cluster on AWS EC2.

  2. Docker Image Management: Building and pushing Docker images for the application.

  3. Kubernetes Deployment and Service Configuration: Defining deployment and service YAML files for Kubernetes.

  4. Verification and Validation: Ensuring correct application deployment and functionality.

  5. 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!