zkt25/z2/myproject
Santhosh 6a0b81d888 ssk
2025-04-30 10:02:24 +02:00
..
k8s changes in dir 2025-04-15 21:57:57 +02:00
myapp changes in dir 2025-04-15 21:57:57 +02:00
myproject changes in dir 2025-04-15 21:57:57 +02:00
scripts changes in dir 2025-04-15 21:57:57 +02:00
.start.sh.swp ssk 2025-04-30 10:02:24 +02:00
docker-compose.yml changes in dir 2025-04-15 21:57:57 +02:00
Dockerfile changes in dir 2025-04-15 21:57:57 +02:00
manage.py changes in dir 2025-04-15 21:57:57 +02:00
prepare-app.sh changes in dir 2025-04-15 21:57:57 +02:00
README.md ssk 2025-04-30 10:02:24 +02:00
remove-app.sh changes in dir 2025-04-15 21:57:57 +02:00
requirements.txt changes in dir 2025-04-15 21:57:57 +02:00
start-app.sh changes in dir 2025-04-15 21:57:57 +02:00
start.sh ssk 2025-04-30 10:02:24 +02:00
stop-app.sh changes in dir 2025-04-15 21:57:57 +02:00
wait-for-it.sh changes in dir 2025-04-15 21:57:57 +02:00

Django with PostgreSQL on Kubernetes

This project demonstrates how to deploy a Django application with PostgreSQL database on Kubernetes.

Project Structure

├── Dockerfile # Docker configuration for Django app ├── docker-compose.yml # Docker Compose configuration (if applicable) ├── k8s/ # Kubernetes configuration files │ ├── namespace.yaml # Namespace configuration │ ├── statefulset.yaml # PostgreSQL StatefulSet with PV/PVC │ ├── deployment.yaml # Django application deployment │ ├── service.yaml # Django service (NodePort) │ ├── migrate-job.yaml # Job for Django migrations ├── manage.py # Django management script ├── myapp/ # Django app directory ├── myproject/ # Django project directory ├── requirements.txt # Python dependencies ├── scripts/ # Utility scripts ├── wait-for-it.sh # DB connection checker └── *.sh # Various utility scripts

Utility Scripts prepare-app.sh: Prepares the application for deployment

start-app.sh: Starts the application

stop-app.sh: Stops the application

remove-app.sh: Removes the application

stat.sh: Shows application status

wait-for-it.sh: Waits for database to be ready

Prerequisites

  • Kubernetes cluster (Minikube or cloud provider)
  • kubectl configured to access your cluster
  • Docker installed (for building images)

Deployment Steps

  1. Build the Django Docker image:
    docker build -t django-app:latest .
    
    
    
    

#Troubleshooting

kubectl get pods -n webapp-namespace

kubectl logs -n webapp-namespace

kubectl get svc -n webapp-namespace

kubectl get pv,pvc -n webapp-namespace

#clean kubectl delete namespace webapp-namespace

minikube service django-service --url -n webapp-namespace

kubectl exec -it postgres-0 -n webapp-namespace -- psql -U myuser -d mydatabase