This guide provides a straightforward approach to deploying a Django application on Google Kubernetes Engine (GKE). It's designed to be simple and educational.
Follow the Google Cloud Platform (GCP) documentation for creating an Autopilot GKE cluster.
Create a Cloud SQL instance along with the necessary user and database. Detailed instructions can be found in the GCP documentation.
Refer to the GCP documentation to create an Artifacts Registry. You will need this registry later in your .env
file under DOCKER_TAG
.
Clone the repository from GitHub:
git clone [email protected]:MarkosMuche/gke_django.git
Remove the .sample
extension from .env.sample
and populate the values:
POSTGRES_PASS= <your_cloudsql_password>
POSTGRES_HOST= <your_cloudsql_public_ip>
POSTGRES_USER= <your_cloudsql_user>
POSTGRES_PORT=5432
POSTGRES_DB= <your_cloudsql_database_name>
DOCKER_TAG= <path_to_your_artifacts_registry>/<your_image_name>:<your_tag>
Execute the script to build and push the Docker image:
bash build_and_push.sh
Run the script to create Kubernetes secrets:
bash create_secrets.sh
Deploy the application by running:
kubectl create -f app.yaml
That's it! Your Django application is now deployed and running on GKE.