Demo deployment of Mongo DB with Django using K8s
- Take a clone of repository
git clone https://github.com/nishitchittora/kubernetes-django-mongo.git
- Apply the MongoDB Deployment from the
mongo-deployment.yaml
file:kubectl apply -f ./mongo-deployment.yaml
- Query the list of Pods to verify that the MongoDB Pod is running:
kubectl get pods
- Apply the MongoDB Service from the following
mongo-service.yaml
file:kubectl apply -f ./mongo-service.yaml
- Query the list of Services to verify that the MongoDB Service is running:
kubectl get service
- Apply the backend Deployment from the
backend-deployment.yaml
file:kubectl apply -f ./backend-deployment.yaml
- Query the list of Pods to verify that the three backend replicas are running:
kubectl get pods -l app.kubernetes.io/name=django_book -l app.kubernetes.io/component=backend
- Apply the backend service from the
backend-service.yaml
file:kubectl apply -f ./backend-service.yaml
- Query the list of services to verify that the backend service is running:
kubectl get services
- Then finally, Run the following command to forward port
8080
on your local machine to port8000
on the service.kubectl port-forward svc/backend 8000:8000
Deleting the Deployments and Services also deletes any running Pods. Use labels to delete multiple resources with one command.
- Run the following commands to delete all Pods, Deployments, and Services.
kubectl delete deployment -l app.kubernetes.io/name=mongo kubectl delete service -l app.kubernetes.io/name=mongo kubectl delete deployment -l app.kubernetes.io/name=django_book kubectl delete service -l app.kubernetes.io/name=django_book
- Query the list of Pods to verify that no Pods are running:
kubectl get pods