Skip to navigation

Databases, Temporal, and telemetry

View as MarkdownOpen in Claude

Use this page to connect NRO to a CloudNativePG operator, PostgreSQL, Temporal or telemetry collector you already run, to tune managed Temporal and to turn on monitoring. You make each change in your state file. If you do not have one yet, follow Write your state file.

Several sections mention bootstrap, the set of Jobs that run NRO database schema migrations and verify or create Temporal prerequisites before Helmfile installs or upgrades NRO.

Use an existing CloudNativePG operator

CloudNativePG (CNPG) is the Kubernetes operator that runs this stack’s managed PostgreSQL clusters. Set cnpg.install: false to use an operator already installed in the cluster.

Tell the stack where that operator lives. Set cnpg.operatorNamespace to its namespace and cnpg.operatorDeployment to its Deployment name. The default name is cnpg-cloudnative-pg. For example, a Helm release named postgres-operator normally creates the Deployment postgres-operator-cloudnative-pg. Check the operator’s compatibility with the pinned database charts, then set cnpg.expectedImage to its exact image reference.

cnpg.operatorDeployment must be a lowercase DNS label of at most 63 characters. With cnpg.install: true, it also names the operator that the stack installs, which keeps the Deployment and the presync gate aligned. Choose it before installation, because changing it later renames the operator resources. The gate still expects the standard CNPG webhook names, so an installation with custom webhook names needs a Helmfile adaptation.

Use existing backing services

A backing service is a database, Temporal server or telemetry collector that NRO connects to. In managed mode, this Helmfile installs and updates that service’s releases in your cluster. In external mode, you supply an existing service and its connection settings; it can run in the same cluster or elsewhere. Choose a mode for each service:

ServiceState keymanaged (default) deploysAlternative
NRO databasedatabase.modenro-dbexternal: the connection string in Secret database.existingSecret, key database.connectionStringKey (default uri; the managed database always uses uri)
Temporaltemporal.modenro-temporal-db, nro-temporalexternal: the frontend at temporal.address, as host:port
Telemetrytelemetry.collectornro-collectorexternal: your OTLP/HTTP endpoints; none: no collector and no endpoints

namespace sets the Kubernetes namespace for NRO and its managed backing-service releases. The CloudNativePG operator’s release uses cnpg.operatorNamespace. temporal.namespace selects the workflow scope inside Temporal; the two names do not have to match.

Have these prerequisites in place before sync:

SettingPrerequisite
database.mode: externalA Secret in the NRO namespace holding a PostgreSQL connection string under database.connectionStringKey
database.mode: externalA database user with permission to create and alter tables. The migration Job uses the same connection string as NRO
database.mode: externalThe pgcrypto, citext, btree_gist and btree_gin extensions, which the migrations create. Install them in the database beforehand, or let the database role create them where your PostgreSQL service permits it
temporal.mode: external, management: verifyThe Temporal namespace temporal.namespace and the five search attributes; the bootstrap Temporal Job fails when they are missing
temporal.mode: external, management: manageA Temporal identity allowed to describe and register namespaces and to list and add search attributes
temporal.auth.mode: apiKey or mtlsThe Secret named by temporal.auth.<mode>.existingSecret
telemetry.collector: externalAn OTLP/HTTP receiver at telemetry.metricsEndpoint, telemetry.tracesEndpoint or both

Mount any certificate files named in the connection string in both NRO and the migration Job (Connect to PostgreSQL over TLS).

The following example uses an existing database, Temporal server and collector. Replace your temporal: block with the one below and add the database: and telemetry: blocks. Also set cnpg.install: false, because no managed database remains:

database:
mode: external
existingSecret: nro-database
temporal:
mode: external
address: temporal-frontend.temporal.svc:7233
namespace: remediation-orchestrator-dev # required in every mode
management: verify # manage creates a missing namespace and search attributes
uiUrl: https://temporal.example.org/namespaces/remediation-orchestrator-dev/
auth:
mode: mtls # none | apiKey | mtls
mtls:
existingSecret: nro-temporal-client
caKey: ca.crt
telemetry:
collector: external
metricsEndpoint: otel-collector.observability.svc:4318
tracesEndpoint: otel-collector.observability.svc:4318

temporal.auth has the same shape as the NRO chart’s temporal.auth (Temporal authentication) and applies only to an external server. External Temporal rejects temporal.web: true, so set temporal.uiUrl to your existing UI instead. NRO appends workflows/<id>/... to that URL, so it must end with /namespaces/<temporal.namespace>/, trailing slash included.

With telemetry.collector: external, a signal whose endpoint is empty keeps the binary default 127.0.0.1:4318, and NRO logs export errors for that signal if nothing listens there. Set both endpoints unless you want only one signal.

telemetry.collector: none leaves the NRO telemetry endpoints unset. The binary then logs export errors unless something listens at its default target.

Several steps wait for the backing services. Presync gates run only for managed databases. First, wait-for-postgresql runs before nro-temporal for the Temporal database and before nro-bootstrap for the NRO database. Then, in every mode, the migration Job’s wait-postgres init container waits for the database. When the optional Temporal Job runs, its temporal container retries each Temporal command while the frontend is unavailable (Skip the bootstrap Temporal Job).

An unreachable external service, or a rejected credential, makes the bootstrap Job retry. The bootstrap Jobs’ own deadlines bound those retries (Deadlines and render checks), and other errors can fail the Job sooner. Any failure prevents bootstrap from completing. If bootstrap does not finish, refer to Bootstrap, application and login.

Switch an installed service to external

The Helmfile renders no release for an external service. Switching a service from managed to external therefore leaves its old release and data in place, and neither sync nor destroy touches them again. After moving the data and taking a backup, remove the old release as a separate step. For the NRO database, run helm -n "$nro_namespace" uninstall nro-db, with nro_namespace set to your state’s namespace. For Temporal, uninstall nro-temporal and then nro-temporal-db.

This retention is Helmfile behavior. A controller that applies a raw render must keep those resources out of its own pruning. It must also apply each release’s namespaced resources into that release’s namespace, because some manifests name no namespace.

Connect to PostgreSQL over TLS

If the connection string names certificate files, such as sslrootcert=/database-tls/ca.crt, those files must exist at the same paths in NRO and in the migration Job. The Job’s wait-postgres init container receives the same mounts. Keep the certificates in a Secret and mount it in both places:

bootstrap:
migrations:
extraVolumes:
- name: database-tls
secret:
secretName: database-client-tls
extraVolumeMounts:
- name: database-tls
mountPath: /database-tls
readOnly: true
remediation-orchestrator:
extraVolumes:
- name: database-tls
secret:
secretName: database-client-tls
extraVolumeMounts:
- name: database-tls
mountPath: /database-tls
readOnly: true

The bootstrap chart’s Database connection section lists the reserved volume names and paths. After changing a certificate behind an unchanged Secret name, restart NRO and change bootstrap.runToken to rerun the migration Job (Rerun the bootstrap Jobs explains the token).

Skip the bootstrap Temporal Job

By default, the bootstrap Temporal Job checks the Temporal namespace and the five search attributes before NRO starts. In manage mode, it creates them when they are missing. Even verify mode needs an identity that can describe the namespace and list its search attributes. If a platform team prepares both on an external server and bootstrap cannot reach that server’s admin APIs, set:

temporal:
mode: external
management: verify
bootstrapJob: false

The Helmfile then sets the bootstrap chart’s temporal.job.enabled: false. The bootstrap chart omits the Temporal Job and its address, namespace and credential requirements. NRO still uses temporal.address, temporal.namespace and temporal.auth. The migration Job still runs. A managed database also keeps its presync gate.

bootstrapJob: false fails with managed Temporal, whose server starts empty. It also fails with temporal.management: manage, because nothing would then create what is missing. The bootstrap chart likewise rejects temporal.management: manage with its Job off. With the Job off, nothing checks the namespace or the search attributes before NRO starts, so keep the Job on whenever bootstrap can reach those APIs.

Managed Temporal

With temporal.mode: managed, the nro-temporal release installs the pinned upstream temporal/temporal 1.7.0 chart against the managed PostgreSQL cluster nro-temporal-db. Tune it through temporal.values (Tune the charts through passthroughs).

Temporal schema migration

The chart’s schema Job nro-temporal-schema is a Helm pre-install,pre-upgrade hook of nro-temporal. It sets up and then updates the temporal and temporal_visibility stores in nro-temporal-db, with the password from Secret nro-temporal-db-app, before Helm creates or updates any Temporal server. CNPG creates both databases, so the Job creates none. Repeating the setup on an initialized store changes nothing, so the hook runs on every upgrade. Before the release, the presync gate wait-for-postgresql checks authenticated SQL on both databases.

A rollback does not revert the schema, so back up nro-temporal-db before a Temporal upgrade. Helm’s --no-hooks (for example through Helmfile --args) skips the migration, so do not pass it.

The schema hook runs within these limits:

  • Its Job deadline (activeDeadlineSeconds) is the top-level state key readiness.timeoutSeconds (default 900), with up to three retries.
  • Helm waits readiness.timeoutSeconds plus 60 seconds for nro-temporal only; every other release keeps readiness.timeoutSeconds. The extra minute is diagnostic headroom for Kubernetes to mark an overrunning Job DeadlineExceeded while Helm is still waiting. It does not guarantee that Helm prints the Job’s final status, so check the Job itself after a failure.
  • A failed hook fails nro-temporal, and Helmfile then deploys none of the releases that need it; the existing servers keep running.
  • A successful Job is deleted. A failed one stays for inspection until the next attempt replaces it, or until schema.ttlSecondsAfterFinished (default 86400 seconds, settable through temporal.values) after the Job finishes.
  • To retry, fix the cause and run sync, as diff and apply explains.

On a fresh database, the first servers create the cluster metadata record when they start. Servers that start at the same time race for it. A loser exits, and its restart reads the winner’s record. That is why a few restarts right after the first install are expected. The bootstrap Temporal Job retries its commands until the frontend answers, and helm test nro-temporal checks temporal operator cluster health.

Anything the schema hook mounts through temporal.values, such as admintools.additionalVolumes, must reference objects that exist before the hook runs, because a pre-install hook runs before the release’s other resources exist.

The chart appends admintools.additionalEnv to the migration containers after the variables that point them at nro-temporal-db, so a later duplicate would override them. For that reason, the stack rejects entries named SQL_PLUGIN, SQL_HOST, SQL_PORT, SQL_DATABASE, SQL_USER or SQL_PASSWORD, with value or valueFrom.

Other names stay open, including SQL_CONNECT_ATTRIBUTES and the SQL_TLS* settings. admintools.additionalEnvSecretName and additionalEnvConfigMapName also stay open, because explicit env entries take precedence over envFrom.

The Temporal ServiceAccount

temporal.values.serviceAccount passes through to the chart. With create: true, the chart creates the account (serviceAccount.name, default nro-temporal) as a pre-install, pre-upgrade hook. Helm deletes and recreates it on every install and upgrade, so its UID changes each time. Helm replaces an existing account of that name, whatever created it. Helm also leaves the account in place on helm uninstall and on a full destroy. The servers, the web UI, the test Pod and the schema hook run as it, so bind roles to it by name.

With create: true, give the account a dedicated serviceAccount.name that nothing else in the namespace uses. Never set it to default or to an account that an application, a database or another release runs as: Helm would delete and recreate that account on every upgrade. The stack does not reject such a name.

When the UID must stay stable, or the account already exists, create it outside the release and set create: false with its name. The servers and the schema hook then run as that account, which must exist (default default). serviceAccount.extraAnnotations and per-component accounts follow the chart’s own values.

To delete a created account after an uninstall, follow Uninstall.

Monitor the stack

NRO and the managed services can create Prometheus Operator monitoring objects. All are off by default.

When remediation-orchestrator.networkPolicy.enabled is true with ingressPeers, as every proxy mode requires, add your Prometheus pods as a peer. The chart never adds one. /metrics shares the HTTP port, so in the proxy modes a scrape peer also reaches the port the identity layer guards (NetworkPolicy).

To turn the monitoring objects on, merge these keys into your state file. Put temporal.values inside your existing temporal: block, and metrics inside any existing remediation-orchestrator: block:

remediation-orchestrator:
metrics:
serviceMonitor:
enabled: true
postgresql:
values:
cluster:
monitoring:
enabled: true
podMonitor:
enabled: true
temporal:
values:
server:
metrics:
serviceMonitor:
enabled: true
KeyEffect
remediation-orchestrator.metrics.serviceMonitorA ServiceMonitor that scrapes NRO’s /metrics on the http port. sync fails unless the cluster serves monitoring.coreos.com/v1/ServiceMonitor. helmfile template does not ask the cluster which APIs it serves, so pass the API to Helm there with --args "--api-versions monitoring.coreos.com/v1/ServiceMonitor" (Operational notes)
postgresql.values.cluster.monitoringSets enablePodMonitor: true on each managed PostgreSQL cluster. The stack defaults monitoring.podMonitor.enabled to false, so set podMonitor.enabled: true together with monitoring.enabled: true, as the example does
temporal.values.server.metrics.serviceMonitorA ServiceMonitor for each Temporal server service: frontend, history, matching and worker. It requires the Prometheus Operator CustomResourceDefinitions (CRDs) in the cluster

For NRO’s own health, request /status. It answers HTTP 503 when its PostgreSQL or Temporal check fails (Endpoints without authentication).

Next steps