|
1 |
| -Kubernetes & Docker Assignment: DJango & MySQL Deployment |
| 1 | +# Kubernetes & Docker Assignment: Django & MySQL Deployment |
| 2 | + |
| 3 | + |
| 4 | +## Overview |
| 5 | + |
| 6 | +In this assignment, you are required to build a containerized application that consists of a Django web application and a MySQL database. The two components will be deployed on a public cloud Kubernetes cluster with proper configuration management. You’ll work with Docker, ConfigMaps, Secrets, Services, and Deployments — and use a MySQL backend in a production-style environment. |
| 7 | + |
| 8 | +## 📦 What’s Provided |
| 9 | + |
| 10 | +- A basic Django project with a single app. |
| 11 | +- Default `settings.py` (Use the Database values from here). |
| 12 | +- Example models and views for testing. |
| 13 | + |
| 14 | +Your task is to containerize the Django application, build and push its Docker image to Docker Hub, and deploy both the Flask app and MySQL database on Kubernetes following the guidelines described below. |
| 15 | + |
| 16 | +## Assignment Requirements |
| 17 | +1. **Containerization & Docker:** |
| 18 | + - Write a `Dockerfile` to containerize the Django application. |
| 19 | + - The image should: |
| 20 | + - Install dependencies from `requirements.txt`. |
| 21 | + - Run migrations automatically. |
| 22 | + - Start the Django development server on port 8000. |
| 23 | + |
| 24 | +2. **Kubernetes Manifests:** |
| 25 | + - **ConfigMaps:** |
| 26 | + - Create a ConfigMap with data containing MYSQL_HOST, MYSQL_PORT and MYSQL_DATABASE. |
| 27 | + - hint (refer to values in django_project/settings.py file) |
| 28 | + - **Secrets:** |
| 29 | + - Create a Secret for the database credentials. (The correct values are: `MYSQL_USER: django`, `MYSQL_PASSWORD: securepassword`.) |
| 30 | + - **MySQL Deployment:** |
| 31 | + - Deploy a Mysql pod use image mysql:8, use the env variables created via ConfigMap and Secret in the above steps. |
| 32 | + - **Django Deployment:** |
| 33 | + - Deploy the Django application using a Deployment use containerport 8000. |
| 34 | + - Configure the Deployment to load environment variables from the ConfigMap and Secret. |
| 35 | + - **Services:** |
| 36 | + - Expose both MySQL (ClusterIP) and Django (LoadBalancer) services. |
| 37 | + - Create a ClusterIP Service for MySQL (Port 3306) Loadbalancer service port 80 and target port 8000. |
| 38 | + |
| 39 | +3. **Validation & Testing:** |
| 40 | + - Ensure that the Django application can connect to the MySQL database using the provided credentials. |
| 41 | + - Use kubectl get svc to get the EXTERNAL-IP of your LoadBalancer. |
| 42 | + Then open: http://<EXTERNAL-IP>/admin. |
0 commit comments