This is a demo django project using docker-compose and kubernetes.
- git
- minikube
- kubectl
- python 3.x
- Django 3.0.2
- gunicorn 0.0.4
- clone this git repo $ git clone git@github.com:KaizenPikachu/demo_django.git
- kubectl apply - django-deployment.yaml
- Create loadbalancer to be able to access the app $ kubectl expose deployment django --type=LoadBalancer --port=8000
- Check status that everything is created correctly $ kubectl get all
- Make service accessable locally through minikube. $ minikube service django
- Django project was generated through pycharm.
- Implemented a django app structure, a webserver (gunicorn), some simple content.
- Implemented a Dockerfile to be able to create docker containers.
- Implemented docker-compose to more easily be able to run the project locally and as a preparation for later steps.
- Build and push containers to dockerhub
- docker build -t maja39/django-demo:0.2 .
- docker push maja39/django-demo:0.2
- Converted docker-compose to kubernetes charts using Kompose. https://www.digitalocean.com/community/tutorials/how-to-migrate-a-docker-compose-workflow-to-kubernetes
- The version of generated was buggy, so I had to convert the yaml file to apiVersion apps/v1
- $ kubectl convert -f django-deployment.yaml --output-version apps/v1
- Note the convert functionality as of now is deprecated, but it will probably only change the way of conversion.
- Write the docker-hub path for the image in the yaml file. In this demo, the docker-hub image is public, but this can obviously be made private.
- Deploy it to kubernetes locally.
- kubectl apply - django-deployment.yaml
- Add a loadbalancer to open up access to the webserver
- $ kubectl expose deployment django --type=LoadBalancer --port=8000
- Expose the service through local routing using minikube
- minikube service django
The local-config.map got generated as a response to the empty .env folder, which I created as a placeholder for when environment variables will be needed. Since it is empty as of now, it don't need to be applied.
minikube ssh top shift m ctrl c ctrl d