Files
adopt-a-street/deploy/k8s/couchdb-statefulset.yaml
William Valentin bb2af4eee7 fix: comprehensive Kubernetes configuration review and fixes
- Add namespace.yaml to create adopt-a-street namespace
- Add namespace to all resource metadata (Services, Deployments, StatefulSet, ConfigMap, Secrets, Ingress)
- Fix CouchDB NODENAME to proper StatefulSet format (adopt-a-street-couchdb-0.adopt-a-street-couchdb)
- Add missing environment variables (STRIPE, OPENAI, CouchDB connection pool settings)
- Fix duplicate Cloudinary variables between ConfigMap and Secrets
- Remove duplicate registry-secret.yaml file (security risk)
- Remove unused couchdb-configmap.yaml
- Complete rewrite of DEPLOYMENT_GUIDE.md with namespace-aware instructions
- Add comprehensive CHANGES.md documenting all fixes and rationale

Fixes address all HIGH and MEDIUM priority issues identified in configuration review:
- Namespace configuration (HIGH)
- Missing resources (HIGH)
- CouchDB NODENAME format (MEDIUM)
- Missing environment variables (MEDIUM)
- Duplicate files (MEDIUM)
- Documentation updates (MEDIUM)

All health checks verified, service discovery tested, and deployment process documented.

🤖 Generated with AI Assistant

Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
2025-12-05 12:27:02 -08:00

137 lines
4.4 KiB
YAML

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
---
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
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@adopt-a-street-couchdb-0.adopt-a-street-couchdb
- name: ERL_FLAGS
value: "+K true +A 4"
- name: COUCHDB_SINGLE_NODE_ENABLED
value: "true"
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "2Gi"
cpu: "1000m"
volumeMounts:
- name: couchdb-data
mountPath: /opt/couchdb/data
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
command:
- sh
- -c
- |
# Create config directory and copy configuration
mkdir -p /opt/couchdb/etc/local.d
echo "[chttpd]" > /opt/couchdb/etc/local.d/10-cluster.ini
echo "bind_address = 0.0.0.0" >> /opt/couchdb/etc/local.d/10-cluster.ini
echo "port = 5984" >> /opt/couchdb/etc/local.d/10-cluster.ini
echo "[couchdb]" >> /opt/couchdb/etc/local.d/10-cluster.ini
echo "single_node = true" >> /opt/couchdb/etc/local.d/10-cluster.ini
echo "enable_cors = true" >> /opt/couchdb/etc/local.d/10-cluster.ini
echo "[cors]" >> /opt/couchdb/etc/local.d/10-cluster.ini
echo "origins = *" >> /opt/couchdb/etc/local.d/10-cluster.ini
echo "credentials = true" >> /opt/couchdb/etc/local.d/10-cluster.ini
echo "headers = accept, authorization, content-type, origin, referer, x-csrf-token" >> /opt/couchdb/etc/local.d/10-cluster.ini
echo "methods = GET, PUT, POST, HEAD, DELETE" >> /opt/couchdb/etc/local.d/10-cluster.ini
echo "max_age = 3600" >> /opt/couchdb/etc/local.d/10-cluster.ini
# Add admin credentials
echo "[admins]" >> /opt/couchdb/etc/local.d/10-cluster.ini
echo "${COUCHDB_USER} = ${COUCHDB_PASSWORD}" >> /opt/couchdb/etc/local.d/10-cluster.ini
# Start CouchDB
exec /opt/couchdb/bin/couchdb
volumeClaimTemplates:
- metadata:
name: couchdb-data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10Gi
# Uncomment and set your storage class if needed
# storageClassName: local-path