Skip to main content

Configuration reference

Synced from product-master

This page is a copy of docs/docs/operations/configuration.md on develop, derived from that repository's code. Edit it there, then re-sync.

Every binary is configured by environment variables only: there is no config file and no flag. Postgres and Kafka are the only runtime (ADR 0010): the mandatory variables below have no default and no fallback, and a missing or rejected value stops the boot with an error that names the variable, before the listener binds. This page lists every variable each binary reads, taken from its composition root (cmd/<binary>/main.go) and from the two adapters that read the environment themselves (internal/adapters/inbound/http/server.go and internal/adapters/outbound/telemetry/telemetry.go).

An empty value is treated like an unset one everywhere (every binary's getenv helper falls back to the default when the value is "").

There is no authentication variable on any binary: REST, MCP and the reports API are unauthenticated fleet-wide, and access control is the cluster boundary.

cmd/api (REST API, outbox relay)​

VariableDefaultRequiredMeaningSource
HTTP_ADDR:8080noListen address of the REST server.cmd/api/main.go (run)
DATABASE_URLnoneyesPostgres DSN of the OLTP database. Missing: exits with DATABASE_URL is required: this context runs on real Postgres. Runs the embedded migrations, opens a pgxpool (max 10 connections, statement_timeout 5s) and pings it, both with the boot retry.cmd/api/config.go (loadBootConfig), cmd/api/adapters.go (buildAdapters), internal/adapters/outbound/postgres/pool.go
MIGRATIONS_DATABASE_URLvalue of DATABASE_URLnoDSN used only for the golang-migrate step. Point it at a direct Postgres connection when DATABASE_URL goes through PgBouncer: golang-migrate's session advisory lock does not survive transaction pooling. The runtime pool always uses DATABASE_URL.cmd/api/adapters.go (migrationsDatabaseURL)
KAFKA_BROKERSnoneyesComma-separated broker list (entries are trimmed, empty ones dropped). Missing: exits with KAFKA_BROKERS is required: this context runs on real Kafka. The outbox relay always runs on it. Kafka is dialled lazily, so a broker that is down at boot does not stop the process; /readyz reports it instead.cmd/api/config.go (brokersFromEnv, loadBootConfig), cmd/api/relay.go (startOutboxRelay)
EVENT_PUBLISHERkafkanoKept because the chart and warehouse-infra set it. Unset and kafka are the only accepted values: log stops the boot with EVENT_PUBLISHER=log is not supported: this context publishes to real Kafka, anything else with unknown EVENT_PUBLISHER. There is no log sink.cmd/api/config.go (checkEventPublisher)
OUTBOX_RELAY_INTERVAL1snoSleep between relay passes that did not fill a batch of 100. Go duration (500ms, 2s) or plain seconds (0.5, 2). Malformed or non-positive values log a WARN and use 1s.cmd/api/config.go (parseRelayInterval), internal/adapters/outbound/outbox/relay.go
OUTBOX_MAX_ATTEMPTS20noRelay attempt cap (ADR 0007): a row that failed this many times is no longer claimed and is logged once at ERROR; it stays in outbox_events until re-armed (UPDATE outbox_events SET attempts = 0 WHERE id = ..., see the runbook). 0 = unlimited. Negative or unparsable values log a WARN and use 20. Chart: config.outboxMaxAttempts.cmd/api/config.go (outboxMaxAttempts), internal/adapters/outbound/outbox/relay.go
SHUTDOWN_DRAIN_DELAY5snoWait between flipping /readyz to 503 and closing the listener on SIGTERM. Go duration only; 0 disables the wait; negative or unparsable values log a WARN and use 5s.cmd/api/config.go (shutdownDrainDelay)
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noOTLP/gRPC collector (insecure) for traces and metrics. Export never blocks: without a collector the telemetry is dropped and the service runs normally.cmd/api/main.go (setupTelemetry), internal/adapters/outbound/telemetry/telemetry.go
LOG_LEVELinfonodebug, info, warn/warning or error (case-insensitive); anything else is info. Every binary accepts warning like warn.cmd/api/config.go (newLogger)
SERVICE_VERSIONdevnoservice.version resource attribute on every span and metric. The chart sets it to the image tag.cmd/api/main.go (setupTelemetry)
ENVIRONMENTlocalnodeployment.environment.name resource attribute on every span and metric.internal/adapters/outbound/telemetry/telemetry.go (Environment)
CORS_ALLOWED_ORIGINShttp://localhost:5173 (the warehouse-console shell's dev port)noComma-separated browser origins allowed by the CORS middleware (entries are trimmed). Allowed methods GET and PUT, headers Accept and Content-Type, no credentials. Read once, when the router is built. Add http://localhost:5191 to run the standalone remote (web/, npm run dev) against a local API. In the kind cluster Kong's CORS plugin handles browsers, so the chart leaves it unset.internal/adapters/inbound/http/server.go (corsAllowedOrigins)

cmd/mcp (MCP server; read-only except two pack level tools)​

VariableDefaultRequiredMeaningSource
MCP_ADDR:8090noListen address. MCP Streamable HTTP is served at / and /mcp, GET /healthz beside it.cmd/mcp/main.go (run)
DATABASE_URLnoneyesThe same OLTP database as cmd/api. Missing: exits with DATABASE_URL is required: this context runs on real Postgres (no in-memory repository). Migrates, connects (max 10 connections) and pings with the boot retry.cmd/mcp/main.go (run, buildDeps)
MIGRATIONS_DATABASE_URLvalue of DATABASE_URLnoDirect DSN for the boot migrations only. cmd/mcp runs the same idempotent embedded migrations as cmd/api, so it can start first on a fresh database.cmd/mcp/main.go (run, buildDeps)
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noOTLP/gRPC collector. Service name product-master-mcp.cmd/mcp/main.go, cmd/mcp/router.go
LOG_LEVELinfonodebug, info, warn/warning or error.cmd/mcp/main.go (newLogger)
SERVICE_VERSIONdevnoservice.version resource attribute.cmd/mcp/main.go
ENVIRONMENTlocalnodeployment.environment.name resource attribute.internal/adapters/outbound/telemetry/telemetry.go

cmd/mcp reads no Kafka variable and no EVENT_PUBLISHER: it never starts the outbox relay and never dials a broker. Its two write tools (declare_pack_level, retire_pack_level, ADR 0011) insert the pack level rows and the outbox rows into DATABASE_URL's database in one transaction; the relay in cmd/api publishes them, so the database role of DATABASE_URL needs write access to products, product_pack_levels and outbox_events.

cmd/product-projector (analytics writer)​

VariableDefaultRequiredMeaningSource
ANALYTICS_DATABASE_URLnoneyesDSN of the separate analytical database (product_master_analytics in the kind cluster), read-write and direct (not PgBouncer): the projector runs the embedded analytical migrations on start. Missing: exits with ANALYTICS_DATABASE_URL is required. Pool: max 5 connections, statement_timeout 10s.cmd/product-projector/main.go (loadConfig), internal/adapters/outbound/analyticsstore/pool.go
KAFKA_BROKERSnoneyesComma-separated brokers (entries are trimmed, empty ones dropped). Missing: exits with KAFKA_BROKERS is required.cmd/product-projector/main.go (loadConfig)
ANALYTICS_CONSUMER_GROUPnoneyesThe projector's fixed consumer group on warehouse.product-master.analytics. Missing: exits with ANALYTICS_CONSUMER_GROUP is required. A new group id starts from the earliest offset and rebuilds the model from history. The chart always sets it (analytics.projector.consumerGroup, product-master-analytics).cmd/product-projector/main.go (loadConfig)
ADMIN_ADDR:8091noListen address of the admin server (/healthz, /readyz only).cmd/product-projector/main.go
LOG_LEVELinfonodebug, info, warn/warning or error.cmd/product-projector/main.go (newLogger)
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noOTLP/gRPC collector. Service name product-master-projector (ADR 0008). Export never blocks boot.cmd/product-projector/main.go (setupTelemetry)
SERVICE_VERSIONdevnoservice.version resource attribute.cmd/product-projector/main.go (setupTelemetry)
ENVIRONMENTlocalnodeployment.environment.name resource attribute.internal/adapters/outbound/telemetry/telemetry.go

The projector never opens the OLTP database (DATABASE_URL is not read).

cmd/product-reports (analytics reader)​

VariableDefaultRequiredMeaningSource
ANALYTICS_DATABASE_URLnoneyesDSN of the analytical database, ideally a read-only role. Missing: exits with ANALYTICS_DATABASE_URL is required. The pool also forces default_transaction_read_only=on (max 5 connections, statement_timeout 15s). In the chart this variable is fed from the secret key ANALYTICS_READER_DATABASE_URL.cmd/product-reports/main.go, internal/adapters/outbound/analyticsstore/pool.go (NewReadOnlyPool)
HTTP_ADDR:8092noListen address of the reports API.cmd/product-reports/main.go
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317noOTLP/gRPC collector. Service name product-master-reports.cmd/product-reports/main.go
LOG_LEVELinfonodebug, info, warn/warning or error.cmd/product-reports/main.go (newLogger)
SERVICE_VERSIONdevnoservice.version resource attribute.cmd/product-reports/main.go
ENVIRONMENTlocalnodeployment.environment.name resource attribute. The chart sets it from environment (ADR 0008).internal/adapters/outbound/telemetry/telemetry.go

Fixed values (not configurable)​

These are constants in code; changing them needs a code change.

ValueConstantSource
Outbox relay batch size: 100 rows per passDefaultBatchSizeinternal/adapters/outbound/outbox/relay.go
Boot retry: 5 attempts, backoff 1s doubling, slept only between attempts (1+2+4+8 = 15 s in total)bootretry.Retries, bootretry.Delayinternal/bootretry/bootretry.go
HTTP graceful drain 10s; relay drain 10sshutdownTimeout, workerDrainTimeoutcmd/api/main.go
/readyz dependency checks: verdict cached 3s, one round bounded to 2sDefaultReadinessTTL, DefaultReadinessTimeoutinternal/adapters/inbound/http/readiness.go
Consumer retry backoff: 200 ms doubling, capped at 5 sDefaultRetryInitial, DefaultRetryMaxinternal/adapters/inbound/kafka/kafka.go
Request body limit 64 KiB; unknown JSON fields rejectedmaxBodyBytesinternal/adapters/inbound/http/response.go
List page size: default 100, max 500DefaultListLimit, MaxListLimitinternal/application/usecases/queries.go
Report range: default 30 days, max 366 daysDefaultWindow, MaxWindowinternal/analytics/report/range.go
OTLP metric export interval 30smetricExportIntervalinternal/adapters/outbound/telemetry/telemetry.go

Helm values that map to these variables​

charts/product-master/values.yaml renders the variables above; the mapping is. The chart refuses to render (naming the value) without database.url or database.existingSecret, without kafka.brokers, with config.eventPublisher other than kafka, with kafka.enabled=false, with a *_MODE variable in extraEnv, and with analytics enabled but no analytical DSN source or no analytics.projector.consumerGroup:

Values keyVariableBinary
config.httpAddrHTTP_ADDRapi
config.logLevelLOG_LEVELapi, mcp, projector, reports
config.eventPublisherEVENT_PUBLISHER (default kafka; the chart refuses any other value)api
config.outboxRelayIntervalOUTBOX_RELAY_INTERVAL (not rendered when empty)api
config.outboxMaxAttemptsOUTBOX_MAX_ATTEMPTS (default 20)api
config.shutdownDrainDelaySHUTDOWN_DRAIN_DELAY (not rendered when empty)api
config.corsAllowedOriginsCORS_ALLOWED_ORIGINS (not rendered when empty)api
environmentENVIRONMENTapi, mcp, projector, reports
image.tag (or chart appVersion)SERVICE_VERSIONapi, mcp, projector, reports
otel.enabled, otel.endpointOTEL_EXPORTER_OTLP_ENDPOINTapi, mcp, projector, reports
database.existingSecret / database.url, key database.existingSecretKeyDATABASE_URLapi, mcp
key database.migrationsExistingSecretKey (optional secret key)MIGRATIONS_DATABASE_URLapi, mcp
kafka.brokers (required, no default; kafka.enabled is accepted but false is refused)KAFKA_BROKERSapi, projector
mcp.httpAddrMCP_ADDRmcp
analytics.projector.adminAddrADMIN_ADDRprojector
analytics.projector.consumerGroupANALYTICS_CONSUMER_GROUPprojector
analytics.reports.httpAddrHTTP_ADDRreports
analytics.database.* (secret keys ANALYTICS_DATABASE_URL, ANALYTICS_READER_DATABASE_URL)ANALYTICS_DATABASE_URLprojector (read-write key), reports (reader key)

See the runbook for how these come together in a deployment.

The api Deployment also mounts the chart ConfigMap (templates/configmap.yaml: HTTP_ADDR, LOG_LEVEL, EVENT_PUBLISHER, ENVIRONMENT, OUTBOX_RELAY_INTERVAL, OUTBOX_MAX_ATTEMPTS, SHUTDOWN_DRAIN_DELAY, CORS_ALLOWED_ORIGINS, OTEL_EXPORTER_OTLP_ENDPOINT, KAFKA_BROKERS; the optional ones only when set) with envFrom (gap fix D14). Every key in it is read by cmd/api. The explicit env entries carry the same values and win for the same key; the checksum/config annotation rolls the pods when the ConfigMap changes. The mcp, projector and reports Deployments do not mount it. charts/product-master/tests/render_test.sh (CI job chart-tests) asserts the mount.