Skip to content

Killingrace/Todo_Helm_Chart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django ToDo List — Helm Chart Deployment

This repository contains a complete project for deploying a ToDo web application (built with the Django framework) to a Kubernetes cluster using a Helm Chart.

The main objective of this project is to demonstrate a reliable and scalable deployment of a multi-component application (web server and database) using modern Infrastructure as Code (IaC) and container orchestration practices.

🏗 Project Architecture

The project consists of the following main components:

  • Web Application (Django): The backend that provides a REST API and an interactive UI (using Skeleton CSS and jQuery). The source code is located in the src/ directory.
  • Database (MySQL): Stores user data and their task lists.
  • Helm Chart (todoapp): The main chart for deploying the application and all required Kubernetes resources.
  • Helm Sub-chart (mysql): A child chart for deploying the MySQL database (as a StatefulSet) with persistent data storage (Persistent Volumes).

⛵ Helm Chart todoapp

All infrastructure configuration is encapsulated within the Helm Chart. Key features and settings include:

  • Configuration Flexibility: All crucial parameters, such as Namespace names, resource names (generated automatically using .Chart.Name), database connections, and secrets, are extracted and managed through the values.yaml file.
  • Secrets and Environment Variables Management: The range function is used to dynamically generate secrets data and conveniently map them into Environment Variables inside the Deployment.
  • Scaling and HPA: A Horizontal Pod Autoscaler (HPA) is configured to automatically scale pods based on resource utilization (e.g., target CPU and memory utilization is configured in values.yaml).
  • Resource Allocation: Clearly defined requests and limits for CPU and RAM to ensure stable operation within the cluster.
  • High Availability:
    • RollingUpdate parameters are configured for seamless updates.
    • Affinity, Node Affinity, and Tolerations are set (e.g., to schedule the database on specific nodes with app=mysql taints and labels).
  • Data Persistence: A PersistentVolumeClaim (PVC) is used for reliable MySQL data storage with specified capacity requirements.
  • Security: Access to the Kubernetes API is restricted using ServiceAccount and corresponding RBAC objects.

🚀 Installation and Deployment

Prerequisites:

  • Docker installed
  • A Kubernetes cluster (we recommend kind)
  • Helm and kubectl installed

Deployment Steps:

  1. Create the cluster: For local testing, you can spin up a cluster using the provided cluster.yml configuration file:

    kind create cluster --config cluster.yml
  2. Prepare nodes (Taints/Labels): Assign the appropriate labels and taints to the database node to ensure correct pod scheduling:

    kubectl taint nodes <node-name> app=mysql:NoSchedule
  3. Deploy using the automated script: For a quick start, you can use the bootstrap.sh script, which contains all the necessary commands to deploy prerequisites and the todoapp Helm Chart to your cluster:

    ./bootstrap.sh

🛠 Local Web Application Development

If you want to run the Django application locally (outside of Kubernetes):

  1. Go to the source directory and install the dependencies (Python 3.8+ required):
    cd src
    pip install -r requirements.txt
  2. Run database migrations:
    python manage.py migrate
  3. Start the development server:
    python manage.py runserver
    The application will be available at: http://localhost:8000/ (API is available at /api/).

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors