apiVersion: v1 kind: ConfigMap metadata: name: atlas-admin-postgres-init data: 10-databases.sh: | #!/bin/sh set -eu psql -U "$POSTGRES_USER" -v ON_ERROR_STOP=1 <<'SQL' \getenv inventory INVENTORY_PASSWORD \getenv identity KC_DB_PASSWORD CREATE ROLE atlas_inventory LOGIN PASSWORD :'inventory'; CREATE ROLE atlas_identity LOGIN PASSWORD :'identity'; CREATE DATABASE itematlas_inventory OWNER atlas_inventory; CREATE DATABASE itematlas_identity OWNER atlas_identity; SQL --- apiVersion: v1 kind: Service metadata: name: atlas-admin-postgres spec: clusterIP: None selector: {app: atlas-admin-postgres} ports: - {name: postgres, port: 5432} --- apiVersion: apps/v1 kind: StatefulSet metadata: name: atlas-admin-postgres spec: serviceName: atlas-admin-postgres replicas: 1 selector: matchLabels: {app: atlas-admin-postgres} template: metadata: labels: {app: atlas-admin-postgres} spec: automountServiceAccountToken: false containers: - name: postgres image: postgres:17.12 envFrom: - secretRef: {name: atlas-admin-postgres} ports: - {name: postgres, containerPort: 5432} readinessProbe: exec: {command: [pg_isready, -h, 127.0.0.1, -U, postgres]} resources: requests: {cpu: 50m, memory: 96Mi} limits: {cpu: '1', memory: 256Mi} volumeMounts: - {name: data, mountPath: /var/lib/postgresql/data} - {name: init, mountPath: /docker-entrypoint-initdb.d, readOnly: true} volumes: - name: init configMap: {name: atlas-admin-postgres-init, defaultMode: 0555} volumeClaimTemplates: - metadata: {name: data} spec: accessModes: [ReadWriteOnce] resources: requests: {storage: 1Gi}