This project aims to provide a comprehensive guide on how to deploy simple web applications using MicroK8s, a lightweight Kubernetes distribution, focusing on two popular frameworks: Django for Python and Gin for Go. By exploring both technologies, developers can gain insights into container orchestration with Kubernetes while also understanding how to build and deploy applications in different programming environments.
- Enable ingress addon which will add nginx ingress controller
microk8s enable ingress
- Create namespaces
microk8s kubectl apply -f ./kube/namespaces.yml
- Create all services, ingress, secret and other items
- For simplicity create variable for version
export version=v<int> name=<string:["django" | "gin"]> path=<string:["." | "./gin/."]>
- Build image
docker build -t ${name}_web:$version ${path:-.}
- Import image into microk8s registry
microk8s ctr image import image_tmp.tar
- Optional: verify the entry
microk8s ctr images ls | rg $name
- Edit
./kube/${name}-deployment.yml
image and put the new version - Save local image
docker save ${name}_web:$version > image_tmp.tar
- for django Edit
./kub/nginx-deployment.yml
as well
- Apply deployment
microk8s kubectl apply -f ./kube/${name}-deployment.yml
unset path
export name=django version=v<bumped_version>
export name=gin version=v<bumped_version> path=./gin/.
- note: some endpoints are supported yet, due to missing db connection.
Run the dashboard microk8s.dashboard-proxy
Sometimes when pods are starting you might see django connection issues and nginx error message. To solve that issue restart pods:
kubectl rollout restart -n backend-django deployment mk8sdjango
Run microk8s kubectl apply -f ./kube/postgres-<name>.yml
:
secrets
volume
configmap
deployment
service
Change the default credentials.
- helm documentation
- gunicorn for django app
- DB for gin app