feat: complete MongoDB to CouchDB migration
- Migrate Report model to CouchDB with embedded street/user data - Migrate UserBadge model to CouchDB with badge population - Update all remaining routes (reports, users, badges, payments) to use CouchDB - Add CouchDB health check and graceful shutdown to server.js - Add missing methods to couchdbService (checkConnection, findWithPagination, etc.) - Update Kubernetes deployment manifests for CouchDB support - Add comprehensive CouchDB setup documentation All core functionality now uses CouchDB as primary database while maintaining MongoDB for backward compatibility during transition period. 🤖 Generated with [AI Assistant] Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
This commit is contained in:
146
deploy/k8s/couchdb-statefulset.yaml
Normal file
146
deploy/k8s/couchdb-statefulset.yaml
Normal file
@@ -0,0 +1,146 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: adopt-a-street-couchdb
|
||||
namespace: adopt-a-street
|
||||
labels:
|
||||
app: couchdb
|
||||
spec:
|
||||
clusterIP: None # Headless service for StatefulSet
|
||||
selector:
|
||||
app: couchdb
|
||||
ports:
|
||||
- port: 5984
|
||||
targetPort: 5984
|
||||
name: couchdb
|
||||
- port: 4369
|
||||
targetPort: 4369
|
||||
name: epmd
|
||||
- port: 9100
|
||||
targetPort: 9100
|
||||
name: couchdb-exporter
|
||||
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: adopt-a-street-couchdb
|
||||
namespace: adopt-a-street
|
||||
spec:
|
||||
serviceName: adopt-a-street-couchdb
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: couchdb
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: couchdb
|
||||
spec:
|
||||
# Place CouchDB on Pi 5 nodes (more RAM)
|
||||
affinity:
|
||||
nodeAffinity:
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
nodeSelectorTerms:
|
||||
- matchExpressions:
|
||||
- key: kubernetes.io/arch
|
||||
operator: In
|
||||
values:
|
||||
- arm64 # Pi 5 architecture
|
||||
containers:
|
||||
- name: couchdb
|
||||
image: couchdb:3.3
|
||||
ports:
|
||||
- containerPort: 5984
|
||||
name: couchdb
|
||||
- containerPort: 4369
|
||||
name: epmd
|
||||
- containerPort: 9100
|
||||
name: couchdb-exporter
|
||||
env:
|
||||
- name: COUCHDB_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: adopt-a-street-secrets
|
||||
key: COUCHDB_USER
|
||||
- name: COUCHDB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: adopt-a-street-secrets
|
||||
key: COUCHDB_PASSWORD
|
||||
- name: COUCHDB_SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: adopt-a-street-secrets
|
||||
key: COUCHDB_SECRET
|
||||
- name: NODENAME
|
||||
value: couchdb@0.adopt-a-street-couchdb.adopt-a-street
|
||||
- name: ERL_FLAGS
|
||||
value: "+K true +A 4"
|
||||
resources:
|
||||
requests:
|
||||
memory: "512Mi"
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "2Gi"
|
||||
cpu: "1000m"
|
||||
volumeMounts:
|
||||
- name: couchdb-data
|
||||
mountPath: /opt/couchdb/data
|
||||
- name: couchdb-config
|
||||
mountPath: /opt/couchdb/etc/local.d
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /_up
|
||||
port: 5984
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /_up
|
||||
port: 5984
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
- name: couchdb-exporter
|
||||
image: gesellix/couchdb-exporter:latest
|
||||
ports:
|
||||
- containerPort: 9100
|
||||
name: metrics
|
||||
env:
|
||||
- name: COUCHDB_URL
|
||||
value: "http://localhost:5984"
|
||||
- name: COUCHDB_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: adopt-a-street-secrets
|
||||
key: COUCHDB_USER
|
||||
- name: COUCHDB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: adopt-a-street-secrets
|
||||
key: COUCHDB_PASSWORD
|
||||
resources:
|
||||
requests:
|
||||
memory: "64Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "128Mi"
|
||||
cpu: "100m"
|
||||
volumes:
|
||||
- name: couchdb-config
|
||||
configMap:
|
||||
name: couchdb-config
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: couchdb-data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
# Uncomment and set your storage class if needed
|
||||
# storageClassName: local-path
|
||||
Reference in New Issue
Block a user