Skip to content

Example of using Skaffold to manage Django+Postgres deployment on Kubernetes

Notifications You must be signed in to change notification settings

ksaaskil/django-postgres-skaffold-k8s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django + Postgres + Skaffold + Kubernetes

Example Django application running on Postgres with Kubernetes deployment using Skaffold. See skaffold.yaml for Skaffold configuration.

⚠️ Pre-requisites

Getting started

The project uses Skaffold to build resources and deploy to Kubernetes. See the configuration in ./skaffold.yaml and manifests in k8s/ folder.

If you want to persist Postgres data, you can create a folder such as ~/postgres-data and mount it to Minikube:

$ mkdir ~/postgres-data
$ minikube mount ~/postgres-data:/mnt1/postgres-data

Build images:

$ skaffold build

Deploy in development mode with hot reloading of code:

$ skaffold dev [--port-forward]

You can test the deployment by making a request to localhost:8080:

$ curl http://localhost:8080/status/
{ "message": "OK" }

Run build and deploy once:

$ skaffold run [--tail] [--port-forward]

Delete resources:

$ skaffold delete

See what Skaffold deploys:

$ skaffold render

Connect to Postgres at forwarded port (here assumed to be 5433):

$ psql -p 5433 -h 127.0.0.1 -Upostgres-user django-db

Debugging

List pods:

$ kubectl get pods

Access Python in Django pod (replace pod name with your store pod):

$ kubectl exec $PODNAME -it -- python manage.py shell

Access psql in Postgres container:

$ kubectl exec postgres-statefulset-0 -it -- psql -Upostgres-user -ddjango-db

About

Example of using Skaffold to manage Django+Postgres deployment on Kubernetes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages