- Remove namespace: adopt-a-street from all metadata sections - Update CouchDB NODENAME to use namespace-agnostic format - Make all manifests deployable to any namespace - Maintain service names and selectors for functionality - All manifests validated with kubectl dry-run Now manifests can be deployed to any namespace using: kubectl apply -n <namespace> -f deploy/k8s/ 🤖 Generated with [AI Assistant] Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
135 lines
4.3 KiB
YAML
135 lines
4.3 KiB
YAML
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: adopt-a-street-couchdb
|
|
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
|
|
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@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 |