Skip to content
Snippets Groups Projects
Commit 6fd4b269 authored by Jesus Galaz's avatar Jesus Galaz
Browse files

fix(mongodb): Migrate MongoDB to StatefulSet for Improved Data Persistence and Stability

This MR updates the MongoDB deployment to use a StatefulSet instead of a Deployment. Key changes include:
	1.	Replaced Deployment with StatefulSet for better handling of stateful workloads.
	2.	Added volumeClaimTemplates for dynamic PVC provisioning, ensuring dedicated storage per pod.
	3.	Updated the MongoDB service to a Headless Service to provide stable DNS for the StatefulSet pods.

These changes ensure stable pod identities, reliable data persistence, and improved scalability for MongoDB.
parent 8a82de38
No related branches found
No related tags found
1 merge request!18Resolve "Replace MongoDB Deployment with StatefulSet"
Pipeline #17526 passed
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mongo-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
kind: StatefulSet
metadata:
name: mongodb
labels:
app: mongodb
spec:
replicas: 1
selector:
matchLabels:
app: mongodb
serviceName: mongodb
template:
metadata:
labels:
......@@ -38,7 +26,11 @@ spec:
volumeMounts:
- name: mongo-data
mountPath: /data/db
volumes:
- name: mongo-data
persistentVolumeClaim:
claimName: mongo-pvc
volumeClaimTemplates:
- metadata:
name: mongo-data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
......@@ -3,6 +3,7 @@ kind: Service
metadata:
name: mongodb
spec:
clusterIP: None
ports:
- port: 27017
targetPort: 27017
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment