Skip to content

Commit e0daa28

Browse files
authored
Update Assignment-Django-App-MySQL.md
1 parent 84c27d2 commit e0daa28

File tree

1 file changed

+68
-35
lines changed

1 file changed

+68
-35
lines changed
Lines changed: 68 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,75 @@
1-
# Kubernetes & Docker Assignment: Django & MySQL Deployment
1+
# πŸ“˜ Kubernetes & Docker Assignment: Django & MySQL Deployment
22

3+
## πŸš€ Overview
34

4-
## Overview
5+
In this assignment, you will build and deploy a containerized Django web application backed by a MySQL database. The two components will be hosted on a public cloud Kubernetes cluster, following production-style best practices.
56

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+
You’ll work with **Docker**, **Kubernetes ConfigMaps**, **Secrets**, **Deployments**, and **Services**, leveraging **MySQL** as the backend. This simulates a real-world DevOps workflow using infrastructure-as-code principles.
78

8-
## πŸ“¦ What’s Provided
9+
---
910

10-
- A basic Django project with a single app.
11-
- Default `settings.py` (Use the Database values from here).
11+
## πŸ“‚ What’s Provided
12+
13+
- A basic Django project with one app.
14+
- A default `settings.py` file (use database values from here).
1215
- Example models and views for testing.
1316

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.
17+
---
18+
19+
## βœ… Assignment Requirements
20+
21+
### 1. 🐳 Containerization with Docker
22+
23+
- Create a `Dockerfile` to containerize the Django application.
24+
- Your Docker image must:
25+
- Install dependencies from `requirements.txt`
26+
- Automatically run database migrations
27+
- Start the Django development server on port **8000**
28+
29+
---
30+
31+
### 2. βš™οΈ Kubernetes Manifests
32+
33+
#### a. 🧾 ConfigMap
34+
35+
- Create a ConfigMap with the following keys:
36+
- `MYSQL_HOST`
37+
- `MYSQL_PORT`
38+
- `MYSQL_DATABASE`
39+
- πŸ’‘ *Hint:* Use the environment variable names referenced in `django_project/settings.py`.
40+
41+
#### b. πŸ” Secret
42+
43+
- Create a Secret containing database credentials:
44+
- `MYSQL_USER: django`
45+
- `MYSQL_PASSWORD: securepassword`
46+
47+
#### c. 🐘 MySQL Deployment
48+
49+
- Deploy MySQL using the `mysql:8` image.
50+
- Use environment variables from the ConfigMap and Secret.
51+
52+
#### d. 🌐 Django Deployment
53+
54+
- Deploy the Django application using your custom Docker image.
55+
- Expose container port **8000**
56+
- Load environment variables from both the ConfigMap and Secret.
57+
58+
#### e. πŸŒ‰ Kubernetes Services
59+
60+
- Create a **ClusterIP** service for MySQL on port **3306**
61+
- Create a **LoadBalancer** service for Django:
62+
- Service port: **80**
63+
- Target port: **8000**
64+
65+
---
66+
67+
## πŸ” Validation & Testing
68+
69+
- Ensure the Django app connects to the MySQL database using the provided credentials.
70+
- Use the following command to retrieve the external IP of your LoadBalancer:
71+
72+
```bash
73+
kubectl get svc
74+
Access the Django Admin Panel at:
75+
http://<EXTERNAL-IP>/admin

0 commit comments

Comments
Β (0)