DevOps Project-9
Project Description
The project involves deploying a Django Todo app on AWS EC2 using Kubeadm Kubernetes cluster.
Kubernetes Cluster helps in Auto-scaling and Auto-healing of your application.
Follow these steps to set up a Kubernetes cluster on AWS EC2 using Kubeadm and deploy a Django application using Docker containers.
1. Setup Kubernetes Cluster:
Launch an EC2 Instance: Log in to your AWS account, navigate to EC2, and click "Launch Instance." Follow the guide for setting up Kubernetes on AWS EC2.
Verify Connection: Ensure a successful connection between the worker and master nodes in your Kubernetes cluster.
2. Deploy Django Application on Kubernetes:
Clone Repository: Clone the Django Todo CICD repository from GitHub:
git clone https://github.com/pmgoriya/django-todo-cicd.git
Build and Run Docker Images: Build and run Docker images for the Django application:
sudo docker build -t pmgoriya/django-todo . sudo docker run -d -p 8000:8000 pmgoriya/django-todo
Login to Docker Hub: Log in to Docker Hub using:
sudo docker login sudo docker push pmgoriya/django-todo:latest
Create deployment.yml file: Create a deployment.yml file for the Kubernetes deployment:
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: pmgoriya/django-todo ports: - containerPort: 8000
Create service.yml file: Create a service.yml file for the Kubernetes service:
apiVersion: v1 kind: Service metadata: name: todo-service spec: type: NodePort selector: app: todo-app ports: - name: http port: 80 targetPort: 8000 nodePort: 30007
Apply Deployment and Service: Apply the deployment.yml and service.yml files:
kubectl apply -f deployment.yaml kubectl apply -f service.yaml
Verify Running Pods: Verify that the pods are running:
kubectl get pods
3. Run and Access the Django Project:
Access the Project: Access the Django project by navigating to the worker node's public IP in a web browser.
Now, you have successfully set up a Kubernetes cluster on AWS EC2, deployed a Django application using Docker containers, and accessed the application on the worker node's public IP.
Thanks for following the project. See you in the next one.