Deploy Smartbox with Kubernetes
The guide covers only Smartbox mandatory components deployment in k8s
This guide shows how to deploy Smartbox in minimal configuration. One instance of PostgreSQL and a two instances of Aidbox (Sandbox and Portal).
To have a production-ready deployment there also should be:
- Database and Aidbox replicas
- Backups and restoring
- Logging and rotations
- Monitoring and Alerting
- Expose Smartbox to the Internet
- Issuing SSL certificates
This guide does not define exposing Smartbox to the Internet
Prerequisites
- Kubernetes cluster is set up and running
kubectl
utility is installed- Two Aidbox licenses are obtained
- Email provider credentials are obtained
- GCP connect credentials are obtained
Prebuilt k8s configuration
- 1.Download the file
- 2.Populate the missed ENVs
- 3.Run the command
kubectl apply -f smartbox.yaml
The smartbox.yaml
is the k8s compiled templates configuration. The configuration components contained in the file are defined further in this guide
Smartbox mandatory ENVs
Common for Portal & Sandbox
- PGUSER
- PGPASSWORD
- BOX_PROVIDER_DEFAULT_* values. See the documentation
Sandbox specific
- PGDATABASE: sandbox
- AIDBOX_LICENSE
- AIDBOX_ADMIN_ID
- AIDBOX_ADMIN_PASSWORD
- AIDBOX_BASE_URL: http://sandbox
- AIDBOX_ZEN_ENTRYPOINT: 'smartbox.dev-portal/box'
- AIDBOX_CLIENT_ID: sandbox-client
- AIDBOX_CLIENT_SECRET: sandbox-secret
- BOX_AUTH_LOGIN__REDIRECT: "/"
Portal specific
- PGDATABASE: smartbox
- AIDBOX_LICENSE
- AIDBOX_ADMIN_ID
- AIDBOX_ADMIN_PASSWORD
- AIDBOX_BASE_URL: http://smartbox
- AIDBOX_CLIENT_ID: portal-client
- AIDBOX_CLIENT_SECRET: portal-secret
- BOX_SMARTBOX_SANDBOX__URL: http://sandbox
- BOX_SMARTBOX_SANDBOX__ADMIN: admin
- BOX_BULK__STORAGE_GCP_* values. See the documentation
BOX_SMARTBOX_SANDBOX__BASIC is deprecated. Use BOX_SMARTBOX_SANDBOX__ADMIN instead
All the available environment variables are defined here
Components templates
Database (PostgreSQL)
Smartbox (as an Aidbox configuration) requires an instance of running PostgreSQL. There should be two databases on a PostgreSQL cluster:
- First is for
Sandbox
instance - Second is for
Portal
instance
Volume
ENVs
Config
StatefulSet
Service
Sandbox
ENVs
kind: ConfigMap
apiVersion: v1
metadata:
name: sandbox
namespace: smartbox
data:
BOX_ID: aidboxone
AIDBOX_ZEN_ENTRYPOINT: 'smartbox.dev-portal/box'
BOX_AUTH_LOGIN__REDIRECT: "/"
PGHOST: aidboxdb
PGDATABASE: sandbox
AIDBOX_STDOUT_PRETTY: 'true'
AIDBOX_PORT: '8080'
AIDBOX_BASE_URL: 'http://sandbox'
PGPORT: '5432'
AIDBOX_FHIR_VERSION: 4.0.1
BOX_PROVIDER_DEFAULT_TYPE: mailgun
Service
kind: Service
apiVersion: v1
metadata:
name: sandbox
namespace: smartbox
spec:
selector:
service: sandbox
ports:
- protocol: TCP
targetPort: 8080
port: 80
Deployment
kind: Deployment
apiVersion: apps/v1
metadata:
name: sandbox
namespace: smartbox
spec:
replicas: 1
selector:
matchLabels:
service: sandbox
template:
metadata:
labels:
service: sandbox
spec:
containers:
- readinessProbe:
httpGet:
scheme: HTTP
path: /health
port: 8080
initialDelaySeconds: 20
timeoutSeconds: 10
periodSeconds: 10
failureThreshold: 6
envFrom:
- configMapRef:
name: sandbox
- secretRef:
name: sandbox
name: main
ports:
- containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
scheme: HTTP
path: /health
port: 8080
initialDelaySeconds: 20
timeoutSeconds: 10
periodSeconds: 10
failureThreshold: 12
imagePullPolicy: Always
image: healthsamurai/smartbox:edge
Portal
ENVs
Service
Deployment
kind: Deployment
apiVersion: apps/v1
metadata:
name: smartbox
namespace: smartbox
spec:
replicas: 1
selector:
matchLabels:
service: smartbox
template:
metadata:
labels:
service: smartbox
spec:
containers:
- readinessProbe:
httpGet:
scheme: HTTP
path: /health
port: 8080
initialDelaySeconds: 20
timeoutSeconds: 10
periodSeconds: 10
failureThreshold: 6
envFrom:
- configMapRef:
name: smartbox
- secretRef:
name: smartbox
name: main
ports:
- containerPort: 8080
protocol: TCP
livenessProbe:
httpGet:
scheme: HTTP
path: /health
port: 8080
initialDelaySeconds: 20
timeoutSeconds: 10
periodSeconds: 10
failureThreshold: 12
imagePullPolicy: Always
image: healthsamurai/smartbox:edge
Prepare a configuration file
To get a k8s configuration file:
- 1.Populate the templates above
- 2.Combine all the templates to the
.yaml
file separating the templates with---
lines
The beginning of the file should look like.
Deploy Smartbox to your cluster
To deploy Smartbox run the command.
kubectl apply -f smartbox.yaml
The result should look like this.
namespace/smartbox created
persistentvolumeclaim/aidboxdb-data created
configmap/aidboxdb-envs created
secret/aidboxdb-envs created
configmap/aidboxdb-config created
statefulset.apps/aidboxdb created
service/aidboxdb created
configmap/sandbox created
secret/sandbox created
service/sandbox created
deployment.apps/sandbox created
configmap/smartbox created
secret/smartbox created
service/smartbox created
deployment.apps/smartbox created
To check if everything is working fine run the command.
kubectl get pods -n smartbox
There should be 3 running pods.
NAME READY STATUS RESTARTS AGE
aidboxdb-0 1/1 Running 1 (31s ago) 99m
sandbox-759d6b46fc-qwzwd 0/1 Running 1 (31s ago) 9m56s
smartbox-979b6dfbb-2bhkn 0/1 Running 1 (31s ago) 9m56s
Last updated 2025-08-19T16:42:17Z