Skip to content

Latest commit

Β 

History

History
78 lines (51 loc) Β· 2.26 KB

File metadata and controls

78 lines (51 loc) Β· 2.26 KB

πŸ“˜ Kubernetes & Docker Assignment: Django & MySQL Deployment

πŸš€ Overview

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.

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.


πŸ“‚ What’s Provided

  • A basic Django project with one app.
  • A default settings.py file (use database values from here).
  • Example models and views for testing.

βœ… Assignment Requirements

1. 🐳 Containerization with Docker

  • Create a Dockerfile to containerize the Django application.
  • Your Docker image must:
    • Install dependencies from requirements.txt
    • Automatically run database migrations
    • Start the Django development server on port 8000

2. Architectural Diagram

Architecture Diagram

3. βš™οΈ Kubernetes Manifests

a. 🧾 ConfigMap

  • Create a ConfigMap with the following keys:
    • MYSQL_HOST
    • MYSQL_PORT
    • MYSQL_DATABASE
  • πŸ’‘ Hint: Use the environment variable names referenced in django_project/settings.py.

b. πŸ” Secret

  • Create a Secret containing database credentials:
    • MYSQL_USER: django
    • MYSQL_PASSWORD: securepassword

c. 🐘 MySQL Deployment

  • Deploy MySQL using the mysql:8 image.
  • Use environment variables from the ConfigMap and Secret.

d. 🌐 Django Deployment

  • Deploy the Django application using your custom Docker image.
  • Expose container port 8000
  • Load environment variables from both the ConfigMap and Secret.

e. πŸŒ‰ Kubernetes Services

  • Create a ClusterIP service for MySQL on port 3306
  • Create a LoadBalancer service for Django:
    • Service port: 80
    • Target port: 8000

πŸ” Validation & Testing

  • Ensure the Django app connects to the MySQL database using the provided credentials.

  • Use the following command to retrieve the external IP of your LoadBalancer:

    kubectl get svc

Access the Django Admin Panel at: http://EXTERNAP-IP/admin