apiVersion: v1 kind: Service metadata: name: adopt-a-street-couchdb namespace: adopt-a-street labels: app: couchdb spec: type: ClusterIP # Regular ClusterIP service (not headless) 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 initContainers: - name: setup-config image: busybox:1.36 command: - sh - -c - | echo "[chttpd]" > /opt/couchdb/etc/local.d/bind.ini echo "bind_address = 0.0.0.0" >> /opt/couchdb/etc/local.d/bind.ini cat /opt/couchdb/etc/local.d/bind.ini volumeMounts: - name: couchdb-data mountPath: /opt/couchdb/data - name: local-config mountPath: /opt/couchdb/etc/local.d 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 resources: requests: memory: "256Mi" cpu: "100m" limits: memory: "1Gi" cpu: "500m" volumeMounts: - name: couchdb-data mountPath: /opt/couchdb/data - name: local-config mountPath: /opt/couchdb/etc/local.d livenessProbe: exec: command: - curl - -f - http://localhost:5984/_up initialDelaySeconds: 60 periodSeconds: 10 timeoutSeconds: 5 failureThreshold: 6 readinessProbe: exec: command: - curl - -f - http://localhost:5984/_up initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 failureThreshold: 6 volumes: - name: local-config emptyDir: {} volumeClaimTemplates: - metadata: name: couchdb-data spec: accessModes: ["ReadWriteOnce"] resources: requests: storage: 10Gi # Uncomment and set your storage class if needed # storageClassName: local-path