Skip to content

nishitchittora/kubernetes-django-mongo

Repository files navigation

Kubernetes Django Deployment with Mongo DB

Demo deployment of Mongo DB with Django using K8s

Steps to follow

  1. Take a clone of repository
    git clone https://github.com/nishitchittora/kubernetes-django-mongo.git
  2. Apply the MongoDB Deployment from the mongo-deployment.yaml file:
    kubectl apply -f ./mongo-deployment.yaml
  3. Query the list of Pods to verify that the MongoDB Pod is running:
    kubectl get pods
  4. Apply the MongoDB Service from the following mongo-service.yaml file:
    kubectl apply -f ./mongo-service.yaml
  5. Query the list of Services to verify that the MongoDB Service is running:
    kubectl get service
  6. Apply the backend Deployment from the backend-deployment.yaml file:
    kubectl apply -f ./backend-deployment.yaml
  7. 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
  8. Apply the backend service from the backend-service.yaml file:
    kubectl apply -f ./backend-service.yaml
  9. Query the list of services to verify that the backend service is running:
    kubectl get services
  10. Then finally, Run the following command to forward port 8080 on your local machine to port 8000 on the service.
    kubectl port-forward svc/backend 8000:8000

Cleaning up

Deleting the Deployments and Services also deletes any running Pods. Use labels to delete multiple resources with one command.

  1. 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
  2. Query the list of Pods to verify that no Pods are running:
    kubectl get pods

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published