diff --git a/components/manifests/base/agent-registry-configmap.yaml b/components/manifests/base/core/agent-registry-configmap.yaml similarity index 100% rename from components/manifests/base/agent-registry-configmap.yaml rename to components/manifests/base/core/agent-registry-configmap.yaml diff --git a/components/manifests/base/ambient-api-server-service.yml b/components/manifests/base/core/ambient-api-server-service.yml similarity index 100% rename from components/manifests/base/ambient-api-server-service.yml rename to components/manifests/base/core/ambient-api-server-service.yml diff --git a/components/manifests/base/backend-deployment.yaml b/components/manifests/base/core/backend-deployment.yaml similarity index 100% rename from components/manifests/base/backend-deployment.yaml rename to components/manifests/base/core/backend-deployment.yaml diff --git a/components/manifests/base/flags.json b/components/manifests/base/core/flags.json similarity index 100% rename from components/manifests/base/flags.json rename to components/manifests/base/core/flags.json diff --git a/components/manifests/base/flags.json.example b/components/manifests/base/core/flags.json.example similarity index 100% rename from components/manifests/base/flags.json.example rename to components/manifests/base/core/flags.json.example diff --git a/components/manifests/base/frontend-deployment.yaml b/components/manifests/base/core/frontend-deployment.yaml similarity index 100% rename from components/manifests/base/frontend-deployment.yaml rename to components/manifests/base/core/frontend-deployment.yaml diff --git a/components/manifests/base/core/kustomization.yaml b/components/manifests/base/core/kustomization.yaml new file mode 100644 index 000000000..a2f3a0986 --- /dev/null +++ b/components/manifests/base/core/kustomization.yaml @@ -0,0 +1,26 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- backend-deployment.yaml +- frontend-deployment.yaml +- operator-deployment.yaml +- public-api-deployment.yaml +- workspace-pvc.yaml +- minio-deployment.yaml +- postgresql-deployment.yaml +- ambient-api-server-service.yml +- unleash-deployment.yaml +- agent-registry-configmap.yaml + +configMapGenerator: +- name: ambient-models + files: + - models.json + options: + disableNameSuffixHash: true +- name: ambient-flags + files: + - flags.json + options: + disableNameSuffixHash: true diff --git a/components/manifests/base/minio-deployment.yaml b/components/manifests/base/core/minio-deployment.yaml similarity index 100% rename from components/manifests/base/minio-deployment.yaml rename to components/manifests/base/core/minio-deployment.yaml diff --git a/components/manifests/base/models.json b/components/manifests/base/core/models.json similarity index 100% rename from components/manifests/base/models.json rename to components/manifests/base/core/models.json diff --git a/components/manifests/base/operator-deployment.yaml b/components/manifests/base/core/operator-deployment.yaml similarity index 100% rename from components/manifests/base/operator-deployment.yaml rename to components/manifests/base/core/operator-deployment.yaml diff --git a/components/manifests/base/postgresql-deployment.yaml b/components/manifests/base/core/postgresql-deployment.yaml similarity index 100% rename from components/manifests/base/postgresql-deployment.yaml rename to components/manifests/base/core/postgresql-deployment.yaml diff --git a/components/manifests/base/public-api-deployment.yaml b/components/manifests/base/core/public-api-deployment.yaml similarity index 100% rename from components/manifests/base/public-api-deployment.yaml rename to components/manifests/base/core/public-api-deployment.yaml diff --git a/components/manifests/base/unleash-deployment.yaml b/components/manifests/base/core/unleash-deployment.yaml similarity index 100% rename from components/manifests/base/unleash-deployment.yaml rename to components/manifests/base/core/unleash-deployment.yaml diff --git a/components/manifests/base/workspace-pvc.yaml b/components/manifests/base/core/workspace-pvc.yaml similarity index 100% rename from components/manifests/base/workspace-pvc.yaml rename to components/manifests/base/core/workspace-pvc.yaml diff --git a/components/manifests/base/kustomization.yaml b/components/manifests/base/kustomization.yaml index fed245583..f9f8a242d 100644 --- a/components/manifests/base/kustomization.yaml +++ b/components/manifests/base/kustomization.yaml @@ -4,37 +4,10 @@ kind: Kustomization metadata: name: vteam-ambient-runner-base -# Common resources across all environments resources: -- namespace.yaml -- crds +- core - rbac -- backend-deployment.yaml -- frontend-deployment.yaml -- operator-deployment.yaml -- public-api-deployment.yaml -- workspace-pvc.yaml -- minio-deployment.yaml -- postgresql-deployment.yaml -- ambient-api-server-secrets.yml -- ambient-api-server-db.yml -- ambient-api-server-service.yml -- unleash-deployment.yaml -- agent-registry-configmap.yaml - -# Model manifest ConfigMap (single source of truth for available models) -# Feature flags ConfigMap (generic flags synced to Unleash on startup) -configMapGenerator: -- name: ambient-models - files: - - models.json - options: - disableNameSuffixHash: true -- name: ambient-flags - files: - - flags.json - options: - disableNameSuffixHash: true +- platform # Default images (can be overridden by overlays) images: diff --git a/components/manifests/base/ambient-api-server-db.yml b/components/manifests/base/platform/ambient-api-server-db.yml similarity index 100% rename from components/manifests/base/ambient-api-server-db.yml rename to components/manifests/base/platform/ambient-api-server-db.yml diff --git a/components/manifests/base/ambient-api-server-secrets.yml b/components/manifests/base/platform/ambient-api-server-secrets.yml similarity index 100% rename from components/manifests/base/ambient-api-server-secrets.yml rename to components/manifests/base/platform/ambient-api-server-secrets.yml diff --git a/components/manifests/base/platform/kustomization.yaml b/components/manifests/base/platform/kustomization.yaml new file mode 100644 index 000000000..69c9ec3d2 --- /dev/null +++ b/components/manifests/base/platform/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- namespace.yaml +- ../crds +- ambient-api-server-secrets.yml +- ambient-api-server-db.yml diff --git a/components/manifests/base/namespace.yaml b/components/manifests/base/platform/namespace.yaml similarity index 100% rename from components/manifests/base/namespace.yaml rename to components/manifests/base/platform/namespace.yaml diff --git a/components/manifests/overlays/local-dev/ambient-api-server-db-json-patch.yaml b/components/manifests/components/ambient-api-server-db/ambient-api-server-db-json-patch.yaml similarity index 100% rename from components/manifests/overlays/local-dev/ambient-api-server-db-json-patch.yaml rename to components/manifests/components/ambient-api-server-db/ambient-api-server-db-json-patch.yaml diff --git a/components/manifests/overlays/local-dev/ambient-api-server-init-db-patch.yaml b/components/manifests/components/ambient-api-server-db/ambient-api-server-init-db-patch.yaml similarity index 100% rename from components/manifests/overlays/local-dev/ambient-api-server-init-db-patch.yaml rename to components/manifests/components/ambient-api-server-db/ambient-api-server-init-db-patch.yaml diff --git a/components/manifests/components/ambient-api-server-db/kustomization.yaml b/components/manifests/components/ambient-api-server-db/kustomization.yaml new file mode 100644 index 000000000..68fb640d2 --- /dev/null +++ b/components/manifests/components/ambient-api-server-db/kustomization.yaml @@ -0,0 +1,18 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +# Requires: ambient-api-server-db Secret in the target namespace + +patches: +- path: ambient-api-server-db-json-patch.yaml + target: + group: apps + kind: Deployment + name: ambient-api-server-db + version: v1 +- path: ambient-api-server-init-db-patch.yaml + target: + group: apps + kind: Deployment + name: ambient-api-server + version: v1 diff --git a/components/manifests/overlays/production/frontend-oauth-deployment-patch.yaml b/components/manifests/components/oauth-proxy/frontend-oauth-deployment-patch.yaml similarity index 100% rename from components/manifests/overlays/production/frontend-oauth-deployment-patch.yaml rename to components/manifests/components/oauth-proxy/frontend-oauth-deployment-patch.yaml diff --git a/components/manifests/overlays/production/frontend-oauth-service-patch.yaml b/components/manifests/components/oauth-proxy/frontend-oauth-service-patch.yaml similarity index 100% rename from components/manifests/overlays/production/frontend-oauth-service-patch.yaml rename to components/manifests/components/oauth-proxy/frontend-oauth-service-patch.yaml diff --git a/components/manifests/components/oauth-proxy/kustomization.yaml b/components/manifests/components/oauth-proxy/kustomization.yaml new file mode 100644 index 000000000..ab85e1446 --- /dev/null +++ b/components/manifests/components/oauth-proxy/kustomization.yaml @@ -0,0 +1,12 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +patches: +- path: frontend-oauth-deployment-patch.yaml + target: + kind: Deployment + name: frontend +- path: frontend-oauth-service-patch.yaml + target: + kind: Service + name: frontend-service diff --git a/components/manifests/components/postgresql-init-scripts/kustomization.yaml b/components/manifests/components/postgresql-init-scripts/kustomization.yaml new file mode 100644 index 000000000..d8ad221cd --- /dev/null +++ b/components/manifests/components/postgresql-init-scripts/kustomization.yaml @@ -0,0 +1,13 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +resources: +- postgresql-init-scripts.yaml + +patches: +- path: postgresql-init-scripts-patch.yaml + target: + group: apps + version: v1 + kind: Deployment + name: postgresql diff --git a/components/manifests/overlays/e2e/postgresql-init-scripts-patch.yaml b/components/manifests/components/postgresql-init-scripts/postgresql-init-scripts-patch.yaml similarity index 100% rename from components/manifests/overlays/e2e/postgresql-init-scripts-patch.yaml rename to components/manifests/components/postgresql-init-scripts/postgresql-init-scripts-patch.yaml diff --git a/components/manifests/overlays/e2e/postgresql-init-scripts.yaml b/components/manifests/components/postgresql-init-scripts/postgresql-init-scripts.yaml similarity index 100% rename from components/manifests/overlays/e2e/postgresql-init-scripts.yaml rename to components/manifests/components/postgresql-init-scripts/postgresql-init-scripts.yaml diff --git a/components/manifests/components/postgresql-rhel/kustomization.yaml b/components/manifests/components/postgresql-rhel/kustomization.yaml new file mode 100644 index 000000000..fadd2cb2f --- /dev/null +++ b/components/manifests/components/postgresql-rhel/kustomization.yaml @@ -0,0 +1,18 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +# Requires: postgresql-credentials Secret in the target namespace + +patches: +- path: postgresql-json-patch.yaml + target: + group: apps + kind: Deployment + name: postgresql + version: v1 +- path: unleash-init-db-patch.yaml + target: + group: apps + kind: Deployment + name: unleash + version: v1 diff --git a/components/manifests/overlays/local-dev/postgresql-json-patch.yaml b/components/manifests/components/postgresql-rhel/postgresql-json-patch.yaml similarity index 100% rename from components/manifests/overlays/local-dev/postgresql-json-patch.yaml rename to components/manifests/components/postgresql-rhel/postgresql-json-patch.yaml diff --git a/components/manifests/overlays/local-dev/unleash-init-db-patch.yaml b/components/manifests/components/postgresql-rhel/unleash-init-db-patch.yaml similarity index 100% rename from components/manifests/overlays/local-dev/unleash-init-db-patch.yaml rename to components/manifests/components/postgresql-rhel/unleash-init-db-patch.yaml diff --git a/components/manifests/overlays/e2e/kustomization.yaml b/components/manifests/overlays/e2e/kustomization.yaml index dc4c5bb73..a05c57bb3 100644 --- a/components/manifests/overlays/e2e/kustomization.yaml +++ b/components/manifests/overlays/e2e/kustomization.yaml @@ -14,8 +14,9 @@ resources: - minio-credentials.yaml - postgresql-credentials.yaml - unleash-credentials.yaml -# PostgreSQL init scripts for database creation -- postgresql-init-scripts.yaml + +components: +- ../../components/postgresql-init-scripts # Patches for e2e environment patches: @@ -58,13 +59,6 @@ patches: version: v1 kind: Deployment name: agentic-operator -# PostgreSQL: add init-scripts volume for database creation -- path: postgresql-init-scripts-patch.yaml - target: - group: apps - version: v1 - kind: Deployment - name: postgresql # E2E images - use local builds (all components) # Runner image is controlled by AMBIENT_CODE_RUNNER_IMAGE in operator-env-patch diff --git a/components/manifests/overlays/kind/kustomization.yaml b/components/manifests/overlays/kind/kustomization.yaml index af20ee366..59b9d55fe 100644 --- a/components/manifests/overlays/kind/kustomization.yaml +++ b/components/manifests/overlays/kind/kustomization.yaml @@ -3,7 +3,7 @@ kind: Kustomization namespace: ambient-code -# Resources (base + e2e-specific) +# Resources (base + kind-specific) resources: - ../../base - secrets.yaml @@ -13,10 +13,11 @@ resources: - minio-credentials.yaml - postgresql-credentials.yaml - unleash-credentials.yaml -# PostgreSQL init scripts for database creation (kind only) -- postgresql-init-scripts.yaml -# Patches for e2e environment +components: +- ../../components/postgresql-init-scripts + +# Patches for kind environment patches: - path: ambient-api-server-jwks-patch.yaml target: @@ -80,13 +81,6 @@ patches: version: v1 kind: Deployment name: public-api -# PostgreSQL: add init-scripts volume for database creation -- path: postgresql-init-scripts-patch.yaml - target: - group: apps - version: v1 - kind: Deployment - name: postgresql # Kind overlay: Use Quay.io production images by default # For local development with local images, use overlays/kind-local/ instead diff --git a/components/manifests/overlays/kind/postgresql-init-scripts-patch.yaml b/components/manifests/overlays/kind/postgresql-init-scripts-patch.yaml deleted file mode 100644 index 96dd78a08..000000000 --- a/components/manifests/overlays/kind/postgresql-init-scripts-patch.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# JSON patch to add init-scripts volume and volumeMount to PostgreSQL -# This enables automatic database creation via /docker-entrypoint-initdb.d/ -- op: add - path: /spec/template/spec/containers/0/volumeMounts/- - value: - name: init-scripts - mountPath: /docker-entrypoint-initdb.d - readOnly: true -- op: add - path: /spec/template/spec/volumes/- - value: - name: init-scripts - configMap: - name: postgresql-init-scripts - defaultMode: 0755 diff --git a/components/manifests/overlays/kind/postgresql-init-scripts.yaml b/components/manifests/overlays/kind/postgresql-init-scripts.yaml deleted file mode 100644 index 3cffcbd1b..000000000 --- a/components/manifests/overlays/kind/postgresql-init-scripts.yaml +++ /dev/null @@ -1,47 +0,0 @@ -# Init scripts ConfigMap for PostgreSQL - creates databases for each service -# Only used in kind overlay (production uses init containers per service) -apiVersion: v1 -kind: ConfigMap -metadata: - name: postgresql-init-scripts - labels: - app: postgresql - app.kubernetes.io/name: postgresql -data: - # Create databases for platform services - # Add new services here as needed - init-databases.sh: | - #!/bin/bash - set -e - - # Function to create database if it doesn't exist - # Uses parameterized queries to avoid SQL injection - create_db_if_not_exists() { - local db_name="$1" - # Validate database name contains only allowed characters - if [[ ! "$db_name" =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]]; then - echo "ERROR: Invalid database name: $db_name" - exit 1 - fi - echo "Checking database: $db_name" - # Check if database exists - if psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -tAc \ - "SELECT 1 FROM pg_database WHERE datname = '$db_name'" | grep -q 1; then - echo "Database $db_name already exists" - else - echo "Creating database: $db_name" - psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -c "CREATE DATABASE $db_name" - psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -c "GRANT ALL PRIVILEGES ON DATABASE $db_name TO $POSTGRES_USER" - fi - echo "Database $db_name ready" - } - - # Create databases for each service - # Unleash feature flags - create_db_if_not_exists "unleash" - - # Add more databases here as services are added: - # create_db_if_not_exists "langfuse" - # create_db_if_not_exists "other_service" - - echo "All databases initialized successfully" diff --git a/components/manifests/overlays/local-dev/kustomization.yaml b/components/manifests/overlays/local-dev/kustomization.yaml index 05ef9ddd5..5e1c321c3 100644 --- a/components/manifests/overlays/local-dev/kustomization.yaml +++ b/components/manifests/overlays/local-dev/kustomization.yaml @@ -16,6 +16,11 @@ resources: - unleash-credentials.yaml - unleash-route.yaml +# Reusable components +components: +- ../../components/postgresql-rhel +- ../../components/ambient-api-server-db + # Patches for local dev environment patches: # Strategic merge patches @@ -39,28 +44,6 @@ patches: name: ambient-api-server # Ambient API Server DB: fix db.host for vteam- namePrefix - path: ambient-api-server-db-credentials-patch.yaml -# Ambient API Server: init container to wait for DB and create database -- path: ambient-api-server-init-db-patch.yaml - target: - group: apps - version: v1 - kind: Deployment - name: ambient-api-server -# Unleash: init container to create database (RHEL doesn't support init scripts) -- path: unleash-init-db-patch.yaml -# PostgreSQL: use RHEL image with proper env vars and mount paths (JSON patch) -- path: postgresql-json-patch.yaml - target: - group: apps - version: v1 - kind: Deployment - name: postgresql -- path: ambient-api-server-db-json-patch.yaml - target: - group: apps - version: v1 - kind: Deployment - name: ambient-api-server-db # Name prefix for local dev resources namePrefix: vteam- diff --git a/components/manifests/overlays/production/ambient-api-server-db-json-patch.yaml b/components/manifests/overlays/production/ambient-api-server-db-json-patch.yaml deleted file mode 100644 index 2888c8260..000000000 --- a/components/manifests/overlays/production/ambient-api-server-db-json-patch.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# JSON patch to replace ambient-api-server-db container for RHEL image -# Replaces volumeMounts to fix mount path for RHEL data directory -# Replaces env vars for RHEL naming convention (POSTGRESQL_* instead of POSTGRES_*) -# Replaces probes to use POSTGRESQL_USER env var -- op: replace - path: /spec/template/spec/containers/0/image - value: registry.redhat.io/rhel10/postgresql-16:10.1 -- op: replace - path: /spec/template/spec/containers/0/env - value: - - name: POSTGRESQL_USER - valueFrom: - secretKeyRef: - name: ambient-api-server-db - key: db.user - - name: POSTGRESQL_PASSWORD - valueFrom: - secretKeyRef: - name: ambient-api-server-db - key: db.password - - name: POSTGRESQL_DATABASE - valueFrom: - secretKeyRef: - name: ambient-api-server-db - key: db.name -- op: replace - path: /spec/template/spec/containers/0/volumeMounts - value: - - name: ambient-api-server-db-data - mountPath: /var/lib/pgsql/data -- op: replace - path: /spec/template/spec/containers/0/readinessProbe/exec/command - value: - - /bin/sh - - -c - - pg_isready -U "$POSTGRESQL_USER" -- op: replace - path: /spec/template/spec/containers/0/livenessProbe/exec/command - value: - - /bin/sh - - -c - - pg_isready -U "$POSTGRESQL_USER" diff --git a/components/manifests/overlays/production/ambient-api-server-init-db-patch.yaml b/components/manifests/overlays/production/ambient-api-server-init-db-patch.yaml deleted file mode 100644 index 408f7b9d5..000000000 --- a/components/manifests/overlays/production/ambient-api-server-init-db-patch.yaml +++ /dev/null @@ -1,60 +0,0 @@ -# Patch ambient-api-server to add init container that waits for the database -# Required for RHEL PostgreSQL which doesn't support /docker-entrypoint-initdb.d/ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: ambient-api-server -spec: - template: - spec: - initContainers: - - name: init-db - image: registry.redhat.io/rhel10/postgresql-16:10.1 - command: - - /bin/bash - - -c - - | - set -e - echo "Waiting for PostgreSQL to be ready (timeout: 10 minutes)..." - MAX_RETRIES=300 - RETRY_COUNT=0 - until pg_isready -h "$PGHOST" -U "$PGUSER"; do - RETRY_COUNT=$((RETRY_COUNT + 1)) - if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then - echo "ERROR: PostgreSQL not ready after 10 minutes, giving up" - exit 1 - fi - echo "PostgreSQL not ready, waiting... (attempt $RETRY_COUNT/$MAX_RETRIES)" - sleep 2 - done - echo "PostgreSQL is ready" - - echo "Checking if database '$PGDATABASE' exists..." - if psql -h "$PGHOST" -U "$PGUSER" -lqt | cut -d \| -f 1 | grep -qw "$PGDATABASE"; then - echo "Database '$PGDATABASE' already exists" - else - echo "Creating database '$PGDATABASE'..." - psql -h "$PGHOST" -U "$PGUSER" -c "CREATE DATABASE $PGDATABASE;" - echo "Database '$PGDATABASE' created successfully" - fi - env: - - name: PGHOST - valueFrom: - secretKeyRef: - name: ambient-api-server-db - key: db.host - - name: PGUSER - valueFrom: - secretKeyRef: - name: ambient-api-server-db - key: db.user - - name: PGPASSWORD - valueFrom: - secretKeyRef: - name: ambient-api-server-db - key: db.password - - name: PGDATABASE - valueFrom: - secretKeyRef: - name: ambient-api-server-db - key: db.name diff --git a/components/manifests/overlays/production/kustomization.yaml b/components/manifests/overlays/production/kustomization.yaml index 9a5d8adef..1f2f5d22c 100644 --- a/components/manifests/overlays/production/kustomization.yaml +++ b/components/manifests/overlays/production/kustomization.yaml @@ -19,47 +19,17 @@ resources: - unleash-route.yaml - operator-config-openshift.yaml +components: +- ../../components/oauth-proxy +- ../../components/postgresql-rhel +- ../../components/ambient-api-server-db + # Patches for production environment -# Unleash: init container to create database (RHEL doesn't support init scripts) -# PostgreSQL: use RHEL image with proper env vars and mount paths (JSON patch) -# Ambient API Server: init container to wait for DB and create database patches: - path: namespace-patch.yaml target: kind: Namespace name: ambient-code -- path: frontend-oauth-deployment-patch.yaml - target: - kind: Deployment - name: frontend -- path: frontend-oauth-service-patch.yaml - target: - kind: Service - name: frontend-service -- path: postgresql-json-patch.yaml - target: - group: apps - kind: Deployment - name: postgresql - version: v1 -- path: ambient-api-server-db-json-patch.yaml - target: - group: apps - kind: Deployment - name: ambient-api-server-db - version: v1 -- path: ambient-api-server-init-db-patch.yaml - target: - group: apps - kind: Deployment - name: ambient-api-server - version: v1 -- path: unleash-init-db-patch.yaml - target: - group: apps - kind: Deployment - name: unleash - version: v1 - path: ambient-api-server-env-patch.yaml target: group: apps diff --git a/components/manifests/overlays/production/postgresql-json-patch.yaml b/components/manifests/overlays/production/postgresql-json-patch.yaml deleted file mode 100644 index 78e40480b..000000000 --- a/components/manifests/overlays/production/postgresql-json-patch.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# JSON patch to replace PostgreSQL container for RHEL image -# Replaces volumeMounts to fix mount path for RHEL data directory -# Replaces env vars for RHEL naming convention (POSTGRESQL_* instead of POSTGRES_*) -# Replaces probes to use POSTGRESQL_USER env var -- op: replace - path: /spec/template/spec/containers/0/image - value: registry.redhat.io/rhel10/postgresql-16:10.1 -- op: replace - path: /spec/template/spec/containers/0/env - value: - - name: POSTGRESQL_USER - valueFrom: - secretKeyRef: - name: postgresql-credentials - key: db.user - - name: POSTGRESQL_PASSWORD - valueFrom: - secretKeyRef: - name: postgresql-credentials - key: db.password - - name: POSTGRESQL_DATABASE - valueFrom: - secretKeyRef: - name: postgresql-credentials - key: db.name -- op: replace - path: /spec/template/spec/containers/0/volumeMounts - value: - - name: data - mountPath: /var/lib/pgsql/data -- op: replace - path: /spec/template/spec/containers/0/readinessProbe/exec/command - value: - - /bin/sh - - -c - - pg_isready -U "$POSTGRESQL_USER" -- op: replace - path: /spec/template/spec/containers/0/livenessProbe/exec/command - value: - - /bin/sh - - -c - - pg_isready -U "$POSTGRESQL_USER" diff --git a/components/manifests/overlays/production/unleash-init-db-patch.yaml b/components/manifests/overlays/production/unleash-init-db-patch.yaml deleted file mode 100644 index e716e5949..000000000 --- a/components/manifests/overlays/production/unleash-init-db-patch.yaml +++ /dev/null @@ -1,55 +0,0 @@ -# Patch Unleash deployment to add init container that creates database -# Required for RHEL PostgreSQL which doesn't support /docker-entrypoint-initdb.d/ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: unleash -spec: - template: - spec: - initContainers: - - name: init-db - image: registry.redhat.io/rhel10/postgresql-16:10.1 - command: - - /bin/bash - - -c - - | - set -e - echo "Waiting for PostgreSQL to be ready (timeout: 10 minutes)..." - MAX_RETRIES=300 - RETRY_COUNT=0 - until pg_isready -h "$PGHOST" -U "$PGUSER"; do - RETRY_COUNT=$((RETRY_COUNT + 1)) - if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then - echo "ERROR: PostgreSQL not ready after 10 minutes, giving up" - exit 1 - fi - echo "PostgreSQL not ready, waiting... (attempt $RETRY_COUNT/$MAX_RETRIES)" - sleep 2 - done - echo "PostgreSQL is ready" - - echo "Checking if database 'unleash' exists..." - if psql -h "$PGHOST" -U "$PGUSER" -lqt | cut -d \| -f 1 | grep -qw unleash; then - echo "Database 'unleash' already exists" - else - echo "Creating database 'unleash'..." - psql -h "$PGHOST" -U "$PGUSER" -c "CREATE DATABASE unleash;" - echo "Database 'unleash' created successfully" - fi - env: - - name: PGHOST - valueFrom: - secretKeyRef: - name: postgresql-credentials - key: db.host - - name: PGUSER - valueFrom: - secretKeyRef: - name: postgresql-credentials - key: db.user - - name: PGPASSWORD - valueFrom: - secretKeyRef: - name: postgresql-credentials - key: db.password