# Self-hosted PostgreSQL with dynamic labels. Each entry under
# `spec.dynamicLabels` runs a shell command on the agent at the
# configured period and stores stdout as the label value. Use this
# for values that change between deployments — engine version,
# replica role, pgBouncer pool name — instead of hard-coding them
# under `metadata.labels`.
apiVersion: almaforge.com/v1
kind: DatabaseTarget
metadata:
  name: orders-postgres
  labels:
    env: prod
    team: payments
spec:
  protocol: postgres
  uri: orders-prod.internal:5432
  dynamicLabels:
    engine_version:
      period: 5m # Refresh every five minutes.
      command: # Argv form; the agent runs the binary directly, no shell parsing.
        - /bin/sh
        - -c
        - psql --version | awk '{print $3}'
