Update oramap to work with mongo

This commit is contained in:
dvirlabs 2026-03-25 01:57:31 +02:00
parent 01e6b3d1c7
commit f8dc9c9bb5
6 changed files with 185 additions and 20 deletions

View File

@ -1,11 +1,11 @@
apiVersion: v2 apiVersion: v2
name: oramap name: oramap
description: Ora Map - Family Location Mapping Application (Microservices Architecture) description: Ora Map - Family Location Mapping Application with MongoDB (Microservices Architecture)
type: application type: application
# Chart version # Chart version
version: 0.2.0 version: 0.3.0
# Application version # Application version
appVersion: "1.0.0" appVersion: "1.0.0"

View File

@ -4,10 +4,11 @@ Helm chart for deploying Ora Map application in Kubernetes with microservices ar
## Architecture ## Architecture
This chart deploys two main components: This chart deploys three main components:
- **Backend**: Node.js Express API server (Port 3000) - **Backend**: Node.js Express API server with MongoDB integration (Port 3000)
- **Frontend**: Nginx serving static files (Port 80) - **Frontend**: Nginx serving static files with API proxy (Port 80)
- **MongoDB**: Database for storing family location data (Port 27017)
## Installation ## Installation
@ -62,6 +63,13 @@ The following table lists the configurable parameters and their default values:
| `ingress.enabled` | Enable ingress | `true` | | `ingress.enabled` | Enable ingress | `true` |
| `ingress.className` | Ingress class name | `traefik` | | `ingress.className` | Ingress class name | `traefik` |
| `ingress.hosts[0].host` | Ingress hostname | `oramap.dvirlabs.com` | | `ingress.hosts[0].host` | Ingress hostname | `oramap.dvirlabs.com` |
| `mongodb.enabled` | Enable MongoDB deployment | `true` |
| `mongodb.image.repository` | MongoDB image repository | `mongo` |
| `mongodb.image.tag` | MongoDB image tag | `7.0` |
| `mongodb.persistence.enabled` | Enable persistent storage | `true` |
| `mongodb.persistence.size` | PVC size | `5Gi` |
| `mongodb.persistence.storageClass` | Storage class name | `""` (default) |
| `mongodb.database` | Database name | `oramap` |
### Example Custom Values ### Example Custom Values
@ -70,6 +78,12 @@ The following table lists the configurable parameters and their default values:
backend: backend:
image: image:
tag: "v1.0.0" tag: "v1.0.0"
mongodb:
persistence:
enabled: true
size: 10Gi
storageClass: "fast-ssd"
replicaCount: 3 replicaCount: 3
frontend: frontend:
@ -107,13 +121,55 @@ ingress:
### Services ### Services
- **Backend Service**: Internal ClusterIP service on port 3000 - **Backend Service**: Internal ClusterIP service on port 3000
- **Frontend Service**: ClusterIP service on port 80 (exposed via Ingress) - **Frontend Service**: ClusterIP
### Ingress ### MongoDB StatefulSet
- Routes external traffic to frontend service - Persistent database storage for family data
- TLS/SSL termination support - Health checks using mongosh
- Configurable hostname and paths - Configurable storage size and class
- Automatic PVC creation
## Database Setup
### Initial Data Seeding
After deployment, seed the database with initial family data:
```bash
# Access the backend pod
kubectl exec -it deployment/oramap-backend -- sh
# Run the seed script
npm run seed
# Or force re-seed
npm run seed:force
```
### MongoDB Access
```bash
# Port-forward to MongoDB
kubectl port-forward svc/oramap-mongodb 27017:27017
# Check StatefulSet
kubectl get statefulset oramap-mongodb
kubectl get pvc
```
### View Logs
```bash
# Backend logs
kubectl logs -l app=oramap-backend
# Frontend logs
kubectl logs -l app=oramap-frontend
# MongoDB logs
kubectl logs oramap-mongodb-0
```
## CI/CD Integration ## CI/CD Integration

View File

@ -24,10 +24,6 @@ spec:
release: {{ .Release.Name }} release: {{ .Release.Name }}
component: backend component: backend
spec: spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers: containers:
- name: backend - name: backend
image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag }}" image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag }}"
@ -40,6 +36,10 @@ spec:
value: "production" value: "production"
- name: PORT - name: PORT
value: "{{ .Values.backend.containerPort }}" value: "{{ .Values.backend.containerPort }}"
{{- if .Values.mongodb.enabled }}
- name: MONGODB_URI
value: "mongodb://{{ include \"oramap.fullname\" . }}-mongodb:27017/{{ .Values.mongodb.database }}"
{{- end }}
livenessProbe: livenessProbe:
httpGet: httpGet:
path: /api/health path: /api/health
@ -80,10 +80,6 @@ spec:
release: {{ .Release.Name }} release: {{ .Release.Name }}
component: frontend component: frontend
spec: spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers: containers:
- name: frontend - name: frontend
image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag }}" image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag }}"

View File

@ -0,0 +1,20 @@
{{- if .Values.mongodb.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "oramap.fullname" . }}-mongodb
labels:
{{- include "oramap.labels" . | nindent 4 }}
app.kubernetes.io/component: database
spec:
type: ClusterIP
clusterIP: None
ports:
- port: 27017
targetPort: 27017
protocol: TCP
name: mongodb
selector:
{{- include "oramap.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: database
{{- end }}

View File

@ -0,0 +1,75 @@
{{- if .Values.mongodb.enabled }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "oramap.fullname" . }}-mongodb
labels:
{{- include "oramap.labels" . | nindent 4 }}
app.kubernetes.io/component: database
spec:
serviceName: {{ include "oramap.fullname" . }}-mongodb
replicas: 1
selector:
matchLabels:
{{- include "oramap.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: database
template:
metadata:
labels:
{{- include "oramap.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: database
spec:
containers:
- name: mongodb
image: "{{ .Values.mongodb.image.repository }}:{{ .Values.mongodb.image.tag }}"
imagePullPolicy: {{ .Values.mongodb.image.pullPolicy }}
ports:
- name: mongodb
containerPort: 27017
protocol: TCP
env:
- name: MONGO_INITDB_DATABASE
value: {{ .Values.mongodb.database }}
livenessProbe:
exec:
command:
- mongosh
- --eval
- "db.adminCommand('ping')"
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
readinessProbe:
exec:
command:
- mongosh
- --eval
- "db.adminCommand('ping')"
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3
resources:
{{- toYaml .Values.mongodb.resources | nindent 12 }}
volumeMounts:
- name: data
mountPath: /data/db
{{- if .Values.mongodb.persistence.enabled }}
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
{{- if .Values.mongodb.persistence.storageClass }}
storageClassName: {{ .Values.mongodb.persistence.storageClass }}
{{- end }}
resources:
requests:
storage: {{ .Values.mongodb.persistence.size }}
{{- else }}
volumes:
- name: data
emptyDir: {}
{{- end }}
{{- end }}

View File

@ -1,7 +1,5 @@
replicaCount: 1 replicaCount: 1
imagePullSecrets: []
# Backend API configuration # Backend API configuration
backend: backend:
image: image:
@ -43,6 +41,26 @@ service:
port: 80 port: 80
targetPort: 80 targetPort: 80
# MongoDB configuration
mongodb:
enabled: true
image:
repository: mongo
tag: "7.0"
pullPolicy: IfNotPresent
persistence:
enabled: true
storageClass: ""
size: 5Gi
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 256Mi
database: oramap
ingress: ingress:
enabled: true enabled: true
className: "traefik" className: "traefik"