Assurance boundary
Use the Kustomize baseline under k8s/base and the deployment overlays under k8s/overlays to configure the application. Before clinical use, obtain the required approvals for infrastructure, identity, network policy, backup restoration, disaster recovery, capacity, penetration testing, residency, privacy, clinical safety and regulatory compliance.
Do not admit clinical traffic until every environment-specific production gate has passed.
Supported profiles
| Overlay | Mode | Operating model |
|---|---|---|
k8s/overlays/prod-single | kubernetes-single-tenant | Replicated API, frontend, and workers for one governed tenant. |
k8s/overlays/prod | kubernetes-multi-tenant | Shared national/regional platform with mandatory signed tenant context and defence-in-depth isolation. |
k8s/overlays/dev | Development | Non-production verification only. |
Included workload controls
- Three API and frontend replicas, two worker replicas, and a one-shot migration Job.
- Non-root containers, dropped Linux capabilities, read-only root filesystems, RuntimeDefault seccomp, and disabled service-account token automount.
- Startup, liveness, and readiness probes; graceful API termination.
- Resource requests and limits, topology spreading, HPA, and PodDisruptionBudgets.
- TLS ingress, Services, default-deny ingress policy, and a portable web-ingress baseline.
- Separate API, frontend, worker, and migration ServiceAccounts.
The production Kustomize resources do not deploy PostgreSQL, Valkey/Redis or OpenSearch. Attach approved HA services or operators with TLS, authentication, monitoring, encrypted storage, backup, and tested recovery.
Prerequisites
- Supported Kubernetes and at least three worker nodes across failure domains.
- CNI-enforced NetworkPolicy, ingress controller, DNS, certificate automation, WAF/API gateway, metrics pipeline, encrypted CSI storage, external secrets, centralized audit/logging, and synchronized time.
- PostgreSQL HA with PITR, a
NOSUPERUSER NOBYPASSRLSapplication account, and a distinct migration owner. - Valkey/Redis HA and OpenSearch HA with approved authentication, TLS, capacity, and recovery.
- Keycloak or another approved OIDC authority with stable tenant and role claims.
- Digest-pinned, signed, scanned backend/frontend images with SBOM and provenance evidence.
- Pinned FHIR IG packages, mappings, openEHR templates, and validator dependencies.
Pin and render the release
Do not use latest in production. Patch the chosen overlay with immutable image digests, production hosts, TLS secret names, resources, replicas, topology, public URLs, and environment settings.
kubectl kustomize k8s/overlays/prod-single > rendered-amcdr.yaml
# or
kubectl kustomize k8s/overlays/prod > rendered-amcdr.yaml
kubectl apply --server-side --dry-run=server -f rendered-amcdr.yaml
The release pipeline should validate manifest schemas, check policy and image signatures, scan for secrets and compare the release with the deployed configuration.
Required multi-tenant posture
AMCDR_ENV=production
AMCDR_INFRASTRUCTURE_MODE=kubernetes-multi-tenant
AMCDR_TENANCY_MODE=multi
AMCDR_TENANT_CONTEXT_REQUIRED=true
AMCDR_TENANT_DATABASE_RLS_ENABLED=true
AMCDR_TENANT_OPENSEARCH_ISOLATION=index
AMCDR_RUN_MIGRATIONS_ON_STARTUP=false
AMCDR_CACHE_WARMUP_BLOCKING_STARTUP=false
AMCDR_FHIR_VALIDATION_MODE=official
AMCDR_FHIR_VALIDATION_FAIL_CLOSED=true
Replicated single tenancy uses kubernetes-single-tenant and single, while retaining signed context and RLS as defence in depth.
Secret and database roles
Supply amcdr-secrets through an approved secret manager or CSI/External Secrets integration. Never apply the example secret template. The API/worker database URL must use a dedicated NOSUPERUSER NOBYPASSRLS role. Only the migration Job receives AMCDR_MIGRATION_DATABASE_URL.
Required secrets include database URLs, Valkey/Redis, OpenSearch, token signing keys, OIDC credentials, and service credentials. Separate patient-portal signing from platform signing. Rehearse rotation and emergency revocation.
Budget PostgreSQL connections against the HPA ceiling:
API max replicas x WEB_CONCURRENCY x (pool size + overflow)
+ worker allowance + migration/operations reserve
Tenant isolation
Every clinical request resolves one immutable tenant from a signed OIDC/bearer claim, verified API credential, or the approved single-tenant default. X-AmCDR-Tenant-ID constrains scope and never grants it. A tenant change requires a newly signed session.
- PostgreSQL forced RLS and cross-tenant reference triggers protect stored data.
- ORM filters and verified transaction context reinforce the database boundary.
- Valkey/Redis keys use
amcdr:tenant:<tenant-id>:.... - Multi-tenant OpenSearch uses tenant-specific index namespaces and PostgreSQL result revalidation.
- API workers and scheduled workers are separated; renewable leases prevent duplicate scheduler ownership.
Negative testing must include missing tenant claims, token/header mismatch, inactive tenant, missing membership, cross-tenant IDs and references, AQL/search attempts, API-key mismatch, cache keys, and OpenSearch index isolation.
Network and ingress
The base web-ingress policy is portable and therefore broad enough for common ingress-controller layouts. The production overlay must restrict it to the actual ingress namespace and pod labels, and add least-privilege egress.
Permit only DNS, PostgreSQL, Valkey/Redis, OpenSearch, OIDC, and explicitly approved terminology, validation, CQL, email, webhook, object-storage, and observability endpoints. Block general internet egress. Keep databases, caches, search, metrics, dashboards, and administration private.
Align gateway and application request limits, preserve forwarding headers only from trusted proxies, require modern TLS, and implement rate, abuse, and denial-of-service controls.
FHIR validator cache
The official validator JAR is included in the backend image. The base runtime directory is ephemeral. Production must bake the approved IG cache into a versioned image, populate a per-pod cache from controlled storage, or attach a validated access-mode-compatible volume. Do not download floating IG versions during clinical requests.
Deployment sequence
- Confirm image evidence, configuration diff, certificates, DNS, identity claims, state services, backup/PITR, and maintenance policy.
- Apply the namespace and approved external secret binding.
- Delete the previous completed migration Job, apply the rendered release, and wait for migration completion.
- Wait for backend, frontend, and worker rollouts.
- Verify health, readiness, performance, and tenant-isolation endpoints.
- Run OIDC, MPI, openEHR, FHIR, SMART, search, cache, worker, audit, and negative tenant smoke tests.
- Promote traffic only after the production gate passes.
kubectl -n amcdr delete job amcdr-schema-migration --ignore-not-found
kubectl apply -f rendered-amcdr.yaml
kubectl -n amcdr wait --for=condition=complete job/amcdr-schema-migration --timeout=30m
kubectl -n amcdr logs job/amcdr-schema-migration --all-containers=true
kubectl -n amcdr rollout status deployment/amcdr-backend --timeout=15m
kubectl -n amcdr rollout status deployment/amcdr-frontend --timeout=10m
kubectl -n amcdr rollout status deployment/amcdr-worker --timeout=15m
Readiness remains closed while schema revision does not match. Use expand/migrate/contract database changes for rolling releases. Roll an image back only when it is compatible with the migrated schema; Alembic downgrade is not an automatic production recovery strategy.
Readiness checks
| Endpoint | Purpose |
|---|---|
/health | Process liveness and schema status summary. |
/readyz | Service traffic gate for schema, database, and required runtime readiness. |
/performance/readiness | Authenticated dependency, cache, search, and latency evidence. |
/admin/tenant-isolation/readiness | Signed context, RLS, database-role, cache/search isolation, and replica posture. |
curl -fsS https://api.example.org/health
curl -fsS -H "Authorization: Bearer ${TOKEN}" \
https://api.example.org/performance/readiness
curl -fsS -H "Authorization: Bearer ${TOKEN}" \
-H "X-AmCDR-Tenant-ID: ${TENANT_ID}" \
https://api.example.org/admin/tenant-isolation/readiness
Multi-tenant promotion requires production_multi_tenant_ready=true.
Scaling and availability
The baseline starts three API pods, three frontend pods, and two workers. Backend HPA scales from 3 to 12 and frontend from 3 to 10. Adjust these starting values after testing the expected workload.
Before scaling, recalculate database connections and confirm cache leases, OpenSearch throughput, ingress limits, validator memory/CPU, worker idempotency, and clinical workload test results. PDBs protect voluntary disruption but do not replace multi-zone capacity and HA state services.
Monitoring
Scrape /metrics through a dedicated private service identity. Pair it with Kubernetes, nodes, ingress, PostgreSQL, Valkey/Redis, OpenSearch, Keycloak, certificate, backup, and synthetic clinical-workflow monitoring.
Every AMCDR Kubernetes overlay publishes standard Prometheus discovery annotations on the backend Service and pods. After the backend deployment is present, run the automatic monitoring activator:
scripts/k8s/enable-monitoring.sh
The activator exits without changes when AMCDR is not deployed on Kubernetes. When Prometheus Operator is present, it installs the AMCDR ServiceMonitor, PrometheusRule, monitoring NetworkPolicy, applies the selectors required by the detected Prometheus custom resource, and publishes the existing platform dashboard for Grafana sidecar discovery. When the Operator is absent, annotation discovery remains available through infra/prometheus/prometheus.kubernetes.yml.
Supply AMCDR_METRICS_BEARER_TOKEN as key AMCDR_METRICS_BEARER_TOKEN in amcdr-secrets through the production external-secret workflow. The ServiceMonitor uses this dedicated credential for /metrics. For clusters with multiple Prometheus instances, set AMCDR_PROMETHEUS_NAMESPACE and AMCDR_PROMETHEUS_NAME before running the activator.
Alert on no ready APIs, schema mismatch, RLS-bypass database role, false tenant readiness, error-budget burn, latency, connection exhaustion, replication lag, backup failure, cache/lease failure, OpenSearch red/missing aliases, worker backlog, OIDC failure, certificate expiry, validator errors, OOM/crash loops, unschedulable pods, HPA saturation, and audit interruption.
Never place patient identifiers, composition UIDs, raw AQL, or clinical values in metrics labels or general infrastructure logs.
Backup and disaster recovery
Define and approve RPO/RTO for each service. PostgreSQL recovery is the clinical-record boundary. OpenSearch and cache are rebuildable, but their recovery time still affects service RTO.
Use Disaster Recovery and Evidence for the dormant controller, production activation gates, service-tier targets, provider-adapter contract, clean-room procedures, strict clinical/MPI/audit reconciliation and evidence bundle.
The optional controller is excluded from the base, suspended, isolated in its own namespace and denied network access by default. Initial BIA targets are RPO 5 minutes/RTO 30 minutes for authoritative clinical and identity data, RTO 30 minutes for authentication and authorization, and RTO 4 hours for rebuildable search, cache, analytics and asynchronous reporting. Governance must approve or replace these targets before activation.
- Automated encrypted PostgreSQL backup and WAL/PITR.
- Secondary-location copies under residency policy.
- Timed restoration into an isolated environment and clinical/schema verification.
- OpenSearch rebuild and snapshot recovery tests.
- Valkey/Redis failover without duplicate scheduled processing.
- OIDC signing-key, secret-manager, certificate, and regional failover exercises.
- Documented data-loss assessment and clinical reconciliation.
A backup is not accepted until restoration has been demonstrated and timed.
Upgrade and incident control
Test migrations against a production-like restored dataset, use staged/canary rollout where compatible, observe the acceptance window, and retain a forward-recovery plan. During an incident, suspend scoped FHIR capabilities, mappings, webhooks, or modules when sufficient; otherwise activate the maintenance gate. Never bypass RLS, tenant context, validation, or audit to restore service.
Production acceptance
- Images are digest-pinned, verified, scanned, traceable, and deployed across failure domains.
- Migration, probes, HPA, PDB, termination, and rollout behavior pass.
- Runtime DB role cannot bypass RLS; migration ownership is separate.
- Tenant denial suite, OIDC, role, key-rotation, network, secret, and audit controls pass.
- openEHR, FHIR, SMART, MPI, terminology, mappings, templates, and validator conformance pass for enabled capabilities.
- Load/endurance, backup restoration, PITR, failover, DR, penetration, residency, privacy, clinical-safety, and regulatory exercises are approved.