Example Django application running on Postgres with Kubernetes deployment using Skaffold. See skaffold.yaml
for Skaffold configuration.
- Minikube or Docker Desktop
kubectl
- Skaffold
- Optional:
kustomize
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
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