This repository contains a demo project created as part of my DevOps studies in the TechWorld with Nana – DevOps Bootcamp.
https://www.techworld-with-nana.com/devops-bootcamp
Demo Project: Install a stateful service (MongoDB) on Kubernetes using Helm
Technologies used: K8s, Helm, MongoDB, Mongo Express, DigitalOcean Kubernetes, Linux
Project Description:
- Create a managed K8s cluster with DigitalOcean Kubernetes
- Deploy replicated MongoDB service in DOKS cluster using a Helm chart
- Configure data persistence for MongoDB with DigitalOcean block storage
- Deploy UI client Mongo Express for MongoDB
- Deploy and configure nginx ingress to access the UI application from browser
Provision a managed Kubernetes cluster through the DigitalOcean dashboard:
Download the kubeconfig file from DigitalOcean, then configure access:
chmod 400 k8s-id-kubeconfig.yaml
export KUBECONFIG=k8s-id-kubeconfig.yamlVerify the connection:
kubectl cluster-info
kubectl get nodesInstall the Helm package manager by following the official installation guide.
helm repo add bitnami https://charts.bitnami.com/bitnamiSearch for the available MongoDB chart versions:
helm search repo bitnami/mongodbFor detailed chart parameters, see the Bitnami MongoDB chart documentation.
Check the available storage classes in your cluster:
kubectl get storageclassSet the appropriate storage class in helm-mongodb.yaml:
persistence:
storageClass: "do-block-storage"helm install mongodb --values helm-mongodb.yaml bitnami/mongodbA PersistentVolumeClaim (PVC) is automatically created for each of the 3 replica pods:
Retrieve the MongoDB secret configuration:
kubectl get secret mongodb -o yamlThe Mongo Express deployment uses the following environment variables to connect to MongoDB (see helm-mongo-express.yaml):
env:
- name: ME_CONFIG_MONGODB_ADMINUSERNAME
value: root
- name: ME_CONFIG_MONGODB_ADMINPASSWORD
valueFrom:
secretKeyRef:
name: mongodb
key: mongodb-root-password
- name: ME_CONFIG_MONGODB_URL
value: "mongodb://$(ME_CONFIG_MONGODB_ADMINUSERNAME):$(ME_CONFIG_MONGODB_ADMINPASSWORD)@mongodb-0.mongodb-headless:27017"Note:
mongodb-0.mongodb-headlessrefers to the first pod in the StatefulSet, resolved via the headless service (verify withkubectl get svc).
Apply the deployment:
kubectl apply -f helm-mongo-express.yamlVerify the pod is running:
kubectl get podAdd the ingress-nginx Helm repository:
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginxInstall the Nginx Ingress Controller:
helm install nginx-ingress ingress-nginx/ingress-nginx --set controller.publishService.enabled=trueVerify the controller is running:
kubectl get pods
kubectl logs nginx-ingress-ingress-nginx-controller-<pod-id>A DigitalOcean Load Balancer is automatically provisioned:
Note the external IP address assigned to the ingress service:
kubectl get svcUpdate the host in helm-ingress.yaml with your external IP (replacing dots with dashes):
- host: <your-ip-address>.nip.io
# Replace <your-ip-address> with your actual external IPApply the ingress rule:
kubectl apply -f helm-ingress.yamlNavigate to http://<your-ip-address>.nip.io in your browser.
Default credentials:
| Field | Value |
|---|---|
| User | admin |
| Password | pass |









