Day 88 Task: Project-9

Day 88 Task: Project-9

Simplify Deployment with Kubernetes for a Resilient Django Todo App on AWS EC2

Project Description

The project involves deploying a Django Todo app on AWS EC2 using the Kubeadm Kubernetes cluster.

Kubernetes Cluster helps in the Auto-scaling and Auto-healing of your application.

🔶 Task-01: Efficient Django Todo App Deployment on AWS EC2 with Kubernetes Cluster: Powering Auto-Scaling and Auto-Healing

  • Setup the Kubernetes cluster using this script:

    1. Launch an EC2 instance:

      • Log in to your AWS account and click "Launch Instance."

      • A working Kubernetes cluster set up with Kubeadm. For setting up Kubernetes on AWS EC2, follow this guide.

    2. Verify the connection with the worker and master node:

Setup Deployment and Service for Kubernetes.:

  1. Clone the django-todo-cicd repo from GitHub:

     git clone https://github.com/Chandreshpatle28/django_todo.git
    

  2. Build and Run the docker images:

     docker build -t chandreshpatle28/django-todo .
     docker run -d -p chandreshpatle28/django-todo
    
  3. Login Docker hub:

     docker push chandreshpatle28/django-todo:latest
    

  4. Create deployment.yml file:

     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: chandreshpatle28/django-todo
             ports:
             - containerPort: 8000
    
  5. Create service.yml file:

     apiVersion: v1
     kind: Service
     metadata:
       name: todo-service
     spec:
       type: NodePort
       selector:
         app: todo-app
       ports:
       - name: http
         port: 80
         targetPort: 8000
         nodePort: 30007
    
  6. Apply the Deployment and service.yml file:

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

  7. Verify pods are running:

  8. Run the project and check it on the worker node public IP: http://3.90.12.207:30007/todos/

    In conclusion, this project has successfully demonstrated the deployment of a Django Todo application on an AWS EC2 instance using a Kubernetes cluster created with Kubeadm. The utilization of Kubernetes in this deployment not only simplifies the management of containerized applications but also empowers the application with auto-scaling and auto-healing capabilities.

    The project followed a systematic approach:

    1. Kubernetes Cluster Setup: The initial steps involved setting up a Kubernetes cluster, connecting worker and master nodes, ensuring a solid foundation for container orchestration.

    2. Docker Image Management: Docker images for the Django Todo app were built and pushed to Docker Hub, ensuring that the application is containerized and readily available for deployment.

    3. Kubernetes Deployment and Service: Kubernetes deployment and service configurations were defined in YAML files to ensure the application runs reliably and is accessible via NodePort.

    4. Verification and Validation: Pod verification was performed to ensure the application was running correctly, and finally, the project was made available via the worker node's public IP.

The deployment of this Django Todo app on AWS EC2 with Kubernetes is a practical example of how modern cloud-native technologies can be used to host, manage, and scale web applications efficiently. By incorporating Kubernetes into the deployment process, the project has demonstrated the potential for auto-scaling and auto-healing, making it a valuable resource for developers and DevOps engineers looking to harness the power of container orchestration in their projects.

As you continue your journey in the realm of cloud and DevOps, this project serves as a solid foundation for understanding the principles and practices of containerization and Kubernetes orchestration. It's a valuable addition to your portfolio and showcases your ability to deploy and manage applications in a cloud-native environment.

Happy learning, and may your future projects be as successful as this one!


Happy Learning :)

Stay in the loop with my latest insights and articles on cloud ☁️ and DevOps ♾️ by following me on Hashnode, LinkedIn (https://www.linkedin.com/in/chandreshpatle28/), and GitHub (https://github.com/Chandreshpatle28).

Thank you for reading! Your support means the world to me. Let's keep learning, growing, and making a positive impact in the tech world together.

#Git #Linux Devops #Devopscommunity #90daysofdevopschallenge #python #docker #Jenkins #Kubernetes #Terraform #AWS #Grafana

Did you find this article valuable?

Support Chandresh Patle's Blog by becoming a sponsor. Any amount is appreciated!