For AI agents: the documentation index is at /docs/aidbox/llms.txt. A Markdown version of this page is available at /docs/aidbox/deployment-and-maintenance/deploy-aidbox/run-aidbox-in-kubernetes/deploy-production-ready-aidbox-to-kubernetes.md or by requesting it with the Accept: text/markdown header.
Aidbox Docs

Deploy Production-ready Aidbox to Kubernetes

Production-ready infrastructure

Key infrastructure elements:

  • Cluster configuration — Node pool and tooling
  • Database — Cloud or self-managed database
  • Aidbox — Aidbox installation
  • Ingress — Gateway API routing and TLS certificates
  • Logging — Collect application and cluster logs
  • Monitoring — Collect, alert, and visualize cluster and application metrics
  • Security — Vulnerability scanning and policy management

Cluster configuration and tooling

Recommended Kubernetes cluster configuration:

  • Small and medium workloads — 3 nodes X 4 VCPU 16 GB RAM
  • Huge workloads — 3 nodes X 8 VCPU X 64 GB RAM

Toolkit required for development and deployment:

  • AWS, GCP, AZURE - Cloud provider CLI and SDK. Depends on your cloud provider:
  • Kubectl - connection and cluster management
  • Helm - Kubernetes package manager
  • Lens - Kubernetes IDE

Optional - Development and Delivery tooling:

  • Terraform - Infrastructure automation tool
  • Grafana tanka - configuration utility for your Kubernetes
  • Argo CD - GitOps delivery and management
  • Flux - set of continuous and progressive delivery solutions for Kubernetes

Database

Managed solution

Aidbox supports all popular managed Postgresql databases. Supported versions - 13 and higher. See more details in this article — Run Aidbox on managed PostgreSQL.

Self-managed solution

For a self-managed solution in Kubernetes, we recommend using the CloudNativePG operator. It provides high availability, automated failover, backups, and seamless PostgreSQL cluster management.

Install CloudNativePG operator

kubectl apply --server-side -f \
  https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/main/releases/cnpg-1.28.0.yaml

Create PostgreSQL cluster

postgres-secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: postgres
  namespace: prod
stringData:
  password: <your-password>
  username: postgres
type: kubernetes.io/basic-auth
postgres-cluster.yaml
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: aidbox-db
  namespace: prod
spec:
  instances: 3
  bootstrap:
    initdb:
      database: aidbox
      owner: postgres
      secret:
        name: postgres
  postgresql:
    parameters:
      shared_buffers: '2GB'
      max_wal_size: '4GB'
      pg_stat_statements.max: '500'
      pg_stat_statements.track: 'all'
      shared_preload_libraries: 'pg_stat_statements'
  resources:
    requests:
      memory: 4Gi
      cpu: '2'
    limits:
      memory: 8Gi
  storage:
    size: 100Gi
    storageClass: managed-premium

CloudNativePG automatically creates services for connecting to the database:

  • aidbox-db-rw — read-write service (primary)
  • aidbox-db-ro — read-only service (replicas)
  • aidbox-db-r — any instance

Configure backups

CloudNativePG supports backups to S3, Azure Blob Storage, and Google Cloud Storage. See CloudNativePG backup documentation for details.

Alternative solutions

Aidbox

First, you must get an Aidbox license on the Aidbox user portal.

You might want to use the Helm charts prepared by our DevOps engineers to make the deployment experience smoother.

Create ConfigMap with all required config and database connection

This ConfigMap example uses our default Aidbox Configuration Project Template. It's recommended to clone this template and bind your Aidbox installation with it.

Aidbox ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
  name: aidbox
  namespace: prod
data:
  BOX_WEB_BASE_URL: https://my.box.url
  BOX_BOOTSTRAP_FHIR_PACKAGES: 'hl7.fhir.r4.core#4.0.1' # your packages
  BOX_FHIR_TERMINOLOGY_SERVICE_BASE_URL: 'https://tx.health-samurai.io/fhir'
  BOX_ID: aidbox
  BOX_WEB_PORT: '8080'
  BOX_OBSERVABILITY_STDOUT_PRETTY_LOG_LEVEL: all
  BOX_INSTANCE_NAME: aidbox
  BOX_METRICS_PORT: '8765'
  BOX_DB_DATABASE: aidbox
  BOX_DB_HOST: db.prod.svc.cluster.local   # database address
  BOX_DB_PORT: '5432'                      # database port
  BOX_FHIR_SCHEMA_VALIDATION: 'true'
  BOX_FHIR_COMPLIANT_MODE: 'true'
  BOX_FHIR_CORRECT_AIDBOX_FORMAT: 'true'
  BOX_FHIR_CREATEDAT_URL: 'https://aidbox.app/ex/createdAt'
  BOX_SEARCH_INCLUDE_CONFORMANT: 'true'
  BOX_FHIR_SEARCH_COMPARISONS: 'true'
  BOX_COMPATIBILITY_VALIDATION_JSON__SCHEMA_REGEX: '#{:fhir-datetime}'
Aidbox Secret
apiVersion: v1
kind: Secret
metadata:
  name: aidbox
  namespace: prod
data:
  BOX_ADMIN_PASSWORD: <admin_password>
  BOX_ROOT_CLIENT_SECRET: <root_client_password>
  BOX_LICENSE: <JWT-LICENSE>    # JWT license from the Aidbox user portal
  BOX_DB_USER: <db_user>         # database username
  BOX_DB_PASSWORD: <db_password> # database password

Aidbox Deployment

Aidbox Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: aidbox
  namespace: prod
spec:
  replicas: 2
  selector:
    matchLabels:
      service: aidbox
  template:
    metadata:
      labels:
        service: aidbox
    spec:
      containers:
        - name: main
          image: healthsamurai/aidboxone:latest
          ports:
            - containerPort: 8080
              protocol: TCP
            - containerPort: 8765
              protocol: TCP
          envFrom:
            - configMapRef:
                name: aidbox
            - secretRef:
                name: aidbox
          livenessProbe:
            httpGet:
              path: /health
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 20
            timeoutSeconds: 10
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 12
          readinessProbe:
            httpGet:
              path: /health
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 20
            timeoutSeconds: 10
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 6
          startupProbe:
            httpGet:
              path: /health
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 20
            timeoutSeconds: 5
            periodSeconds:  5
            successThreshold: 1
            failureThreshold: 4

When Aidbox starts for the first time, resolving all the dependencies takes longer. If you encounter startupProbe failure, you might want to consider increasing the initialDelaySeconds and failureThreshold under the startupProbe spec in the config above.

For running multiple Aidbox replicas, ensure all instances share the same RSA keys and secrets. See Configure Aidbox for details.

To verify that Aidbox started correctly you can check the logs:

kubectl logs -f <aidbox-pod-name>

Create the Aidbox k8s service

Aidbox service
apiVersion: v1
kind: Service
metadata:
  name: aidbox
  namespace: prod
spec:
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
  selector:
    service: aidbox

Ingress

Expose Aidbox through the Kubernetes Gateway API. The cluster needs a Gateway API implementation installed, for example Envoy Gateway, Istio, NGINX Gateway Fabric, Traefik, or a cloud-managed option such as Application Gateway for Containers on AKS or the GKE Gateway controller. See the list of conformant implementations.

Do not use the community Ingress NGINX Controller (kubernetes/ingress-nginx) for new deployments. Kubernetes SIG Network retired the project: it receives no releases or security fixes after March 2026. If your cluster already runs a maintained controller that implements the Ingress API (for example Traefik or the F5 NGINX Ingress Controller), an Ingress resource still works for Aidbox.

CertManager

To provide a secure HTTPS connection you can use paid SSL certificates, issued for your domain, or use LetsEncrypt-issued certificates. In the case of using LetsEncrypt, we recommend installing and configuring Cert Manager with Gateway API support enabled.

Install Cert Manager
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install \
  cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --create-namespace \
  --set crds.enabled=true \
  --set config.apiVersion=controller.config.cert-manager.io/v1alpha1 \
  --set config.kind=ControllerConfiguration \
  --set config.enableGatewayAPI=true

Configure Cluster Issuer:

Cluster Issuer
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: letsencrypt
spec:
  acme:
    email: hello@my-domain.com
    privateKeySecretRef:
      name: issuer-key
    server: https://acme-v02.api.letsencrypt.org/directory
    solvers:
      - http01:
          gatewayHTTPRoute:
            parentRefs:
              - name: aidbox
                namespace: prod
                kind: Gateway

If you use the Multibox image, configure a DNS-01 solver instead to issue a wildcard certificate for the cluster domain: DNS-01 challenge.

Gateway

The cert-manager.io/cluster-issuer annotation tells cert-manager to issue a certificate for every HTTPS listener and store it in the secret from certificateRefs. Set gatewayClassName to the class your Gateway API implementation provides.

Gateway
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: aidbox
  namespace: prod
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt
spec:
  gatewayClassName: <your-gateway-class>
  listeners:
    - name: http
      protocol: HTTP
      port: 80
      hostname: my.box.url
    - name: https
      protocol: HTTPS
      port: 443
      hostname: my.box.url
      tls:
        mode: Terminate
        certificateRefs:
          - name: aidbox-tls

HTTPRoute

Route traffic from the HTTPS listener to the Aidbox service. Raise the request timeout if you load large bundles or run bulk operations, see How to load large FHIR bundles.

HTTPRoute
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: aidbox
  namespace: prod
spec:
  parentRefs:
    - name: aidbox
      sectionName: https
  hostnames:
    - my.box.url
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /
      backendRefs:
        - name: aidbox
          port: 80
      timeouts:
        request: 300s

Now you can test the route

curl https://my.box.url/health

Logging

General logging & audit information can be found in this article — Logging & Audit

Aidbox supports integration with the following systems:

ElasticSearch integration

You can install ECK using the official guide.

Configure Aidbox and ES integration

apiVersion: v1
kind: Secret
metadata:
  name: aidbox
  namespace: prod
data:
  ...
  BOX_OBSERVABILITY_ELASTICSEARCH_URL: http://es-service.es-ns.svc.cluster.local
  BOX_OBSERVABILITY_ELASTICSEARCH_AUTH: <user>:<password>
  ...

DataDog integration

apiVersion: v1
kind: Secret
metadata:
  name: aidbox
  namespace: prod
data:
  ...
  BOX_OBSERVABILITY_DATADOG_API_KEY: <Datadog API Key>
  ...

Monitoring

For monitoring our recommendation is to use the Kube Prometheus stack

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus prometheus-community/kube-prometheus-stack

Create Aidbox metrics service

apiVersion: v1
kind: Service
metadata:
  name: aidbox-metrics
  namespace: prod
  labels:
    operated: prometheus
spec:
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8765
  selector:
    service: aidbox

Create ServiceMonitor config for scrapping metrics data

ServiceMonitor
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    app.kubernetes.io/component: metrics
    release: kube-prometheus
    serviceMonitorSelector: aidbox
  name: aidbox
  namespace: kube-prometheus
spec:
  endpoints:
    - honorLabels: true
      interval: 10s
      path: /metrics
      targetPort: 8765
    - honorLabels: true
      interval: 60s
      path: /metrics/minutes
      targetPort: 8765
    - honorLabels: true
      interval: 10m
      path: /metrics/hours
      targetPort: 8765
  namespaceSelector:
    any: true
  selector:
    matchLabels:
      operated: prometheus

Or you can directly specify the Prometheus scrapers configuration

global:
  external_labels:
    monitor: 'aidbox'
scrape_configs:
  - job_name: aidbox
    scrape_interval: 5s
    metrics_path: /metrics
    static_configs:
      - targets: [ 'aidbox-metrics.prod.svc.cluster.local:8765' ]

  - job_name: aidbox-minutes
    scrape_interval: 30s
    metrics_path: /metrics/minutes
    static_configs:
      - targets: [ 'aidbox-metrics.prod.svc.cluster.local:8765' ]

  - job_name: aidbox-hours
    scrape_interval: 1m
    scrape_timeout: 30s                     
    metrics_path: /metrics/hours
    static_configs:
      - targets: [ 'aidbox-metrics.prod.svc.cluster.local:8765' ]

Alternative solutions

  • VictoriaMetrics — High-Performance Open Source Time Series Database.
  • Thanos — highly available Prometheus setup with long-term storage capabilities.
  • Grafana Mimir — highly available, multi-tenant, long-term storage for Prometheus.

Additional monitoring

System monitoring:

  • node exporter — Prometheus exporter for hardware and OS metrics exposed by *NIX kernels
  • kube state metrics — is a simple service that listens to the Kubernetes API server and generates metrics about the state of the objects
  • cadvisor — container usage metrics

PostgreSQL monitoring:

  • pg_exporter — Prometheus exporter for PostgreSQL server metrics

Alerting

Alerting rules allow you to define alert conditions based on Prometheus expression language expressions and to send notifications about firing alerts to an external service.

Alert rules

Alert for long-running HTTP queries with P99 > 5s in 5m interval

alert: SlowRequests
for: 5m
expr: histogram_quantile(0.99, sum (rate(aidbox_http_request_duration_seconds_bucket[5m])) by (le, route, instance)) > 5
labels: {severity: ticket}
annotations:
  title: Long HTTP query execution
  metric: '{{ $labels.route }}'
  value: '{{ $value | printf "%.2f" }}'

Alert delivery

Alert manager template for Telegram

global:
  resolve_timeout: 5m
  telegram_api_url: 'https://api.telegram.org/'
route:
  group_by: [alertname instance]
  # Default receiver
  receiver: <my-ops-chat>
  routes:
  # Mute watchdog alert
  - receiver: empty
    match: {alertname: Watchdog}
receivers:
- name: empty
- name: <my-ops-chat>
  telegram_configs:
  - chat_id: <chat-id>
    api_url: https://api.telegram.org
    parse_mode: HTML
    message: |-
      <b>[{{ .CommonLabels.instance }}] {{ .CommonLabels.alertname }}</b>
      {{ .CommonAnnotations.title }}
      {{ range .Alerts }}{{ .Annotations.metric }}: {{ .Annotations.value }}
      {{ end }}
    bot_token: <bot-token>

All other integrations you can find on the AlertManager documentation page.

Additional tools

  • Embedded Grafana alerts
  • Grafana OnCall

Security

Vulnerability and security scanners:

Kubernetes Policy Management:

Advanced:

  • Datree — k8s resources linter

Last updated: