Skip to content

Containers and Kubernetes

This page covers packaging the delivered Linux x64 IdentityFlow program in a minimal container image and running it on Kubernetes. For PostgreSQL provisioning, configuration files, and bare-metal/VM installation, start with Install and run IdentityFlow. To try IdentityFlow on a disposable local k3s cluster first, see Evaluate in Kubernetes.

No prebuilt container image is published. Package the delivered linux-x64 program in a local image for Linux/amd64 only using Docker and an empty build directory. Copy the program into that directory as identity-flow, then save the pinned nonroot distroless Dockerfile as runtime.Dockerfile beside it:

# Linux/amd64 release executable; build it separately with build:release.
# Verified public nonroot index on 2026-10-19; update independently of the program.
FROM gcr.io/distroless/static-debian13:nonroot@sha256:e2e927ec666bae08560abb3c55d0659eceabb657f56b6782ab500a9fc7f555e3
COPY --chown=0:0 --chmod=0555 identity-flow /identity-flow
WORKDIR /workspace
ENV NODE_ENV=production HOST=0.0.0.0 PORT=3000
USER 65532:65532
EXPOSE 3000
STOPSIGNAL SIGTERM
ENTRYPOINT ["/identity-flow"]

Save runtime.Dockerfile.dockerignore in the same directory so only the executable enters the build context:

**
!identity-flow

Build the image from that directory:

Terminal window
docker build --platform linux/amd64 --file runtime.Dockerfile --tag identity-flow:local .

The Workflow Test distribution uses a different runtime and does not belong in this image.

Mount your complete installed workflow project read-only at /workspace (Workflow Definitions, hooks, authorization.ts, identity-flow.conf, and installed node_modules). The runtime runs as UID and GID 65532: mounted files must be readable and directories searchable by 65532. Give the container a read-only root filesystem and a separate writable /tmp tmpfs:

Terminal window
docker run --name identity-flow --platform linux/amd64 \
--read-only --tmpfs /tmp:rw,noexec,nosuid,nodev,size=256m \
--mount type=bind,src=/srv/identity-flow/project,dst=/workspace,readonly \
--env NODE_CONFIG_FILE=/workspace/identity-flow.conf \
--env ORIGIN=https://flow.example.com \
--publish 127.0.0.1:3000:3000 \
--stop-timeout 100 identity-flow:local
  • Replace https://flow.example.com with your public HTTPS origin matching auth.oidc.redirectUri, and place an HTTPS reverse proxy in front of the published port.
  • For a private CA, mount its PEM certificate read-only and set --env NODE_EXTRA_CA_CERTS=/certificates/company-ca.pem (readable by UID 65532). Keep TLS certificate verification enabled.
  • There is no shell or in-container HEALTHCHECK: probe http://<container-address>:3000/-/ready externally for HTTP 200 (ready), use docker logs and docker inspect for diagnostics, and run network tools from a separate toolbox container on the same network.
  • Maintain the distroless base digest and the IdentityFlow executable separately: a base-image CVE scan does not cover the embedded Node, musl, or application dependencies inside the executable. Native dynamic .node addons are incompatible with the linuxstatic executable.
  • Size --stop-timeout (and optional SHUTDOWN_TOTAL_TIMEOUT) using the formula in Stop the program.

Deploy the runtime image with strategy.type: Recreate, a non-root read-only security context, a memory-backed /tmp volume, HTTP probes on /-/ready, and terminationGracePeriodSeconds sized above SHUTDOWN_TOTAL_TIMEOUT:

apiVersion: apps/v1
kind: Deployment
metadata:
name: identity-flow
spec:
# Supported replica counts: 1 or 2. More than 2 replicas are unsupported.
replicas: 1
# RollingUpdate is unsupported; stop old pods before starting replacements.
strategy:
type: Recreate
selector:
matchLabels:
app: identity-flow
template:
metadata:
labels:
app: identity-flow
spec:
securityContext:
runAsNonRoot: true
runAsUser: 65532
runAsGroup: 65532
fsGroup: 65532
# Keep above SHUTDOWN_TOTAL_TIMEOUT (see "Stop the program").
terminationGracePeriodSeconds: 120
containers:
- name: identity-flow
image: registry.example.com/identity-flow:your-tag
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
env:
- name: NODE_CONFIG_FILE
value: /workspace/identity-flow.conf
- name: ORIGIN
value: https://flow.example.com
- name: NODE_EXTRA_CA_CERTS
value: /certificates/company-ca.pem
- name: SHUTDOWN_TOTAL_TIMEOUT
value: '110'
- name: IDENTITY_FLOW_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: identity-flow-secrets
key: database-password
- name: IDENTITY_FLOW_OIDC_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: identity-flow-secrets
key: oidc-client-secret
ports:
- name: http
containerPort: 3000
startupProbe:
httpGet:
path: /-/ready
port: http
periodSeconds: 5
failureThreshold: 60
readinessProbe:
httpGet:
path: /-/ready
port: http
periodSeconds: 5
livenessProbe:
httpGet:
path: /-/ready
port: http
periodSeconds: 10
failureThreshold: 3
volumeMounts:
- name: project
mountPath: /workspace
readOnly: true
- name: ca
mountPath: /certificates
readOnly: true
- name: tmp
mountPath: /tmp
volumes:
- name: project
persistentVolumeClaim:
claimName: identity-flow-project
readOnly: true
- name: ca
configMap:
name: identity-flow-ca
- name: tmp
emptyDir:
medium: Memory
sizeLimit: 256Mi
---
apiVersion: v1
kind: Service
metadata:
name: identity-flow
spec:
selector:
app: identity-flow
ports:
- name: http
port: 3000
targetPort: http
  • Workflow project delivery: you can either mount an installed project read-only at /workspace (as shown above) or layer the installed project into your internal container image during your build pipeline. Keep secrets in Kubernetes Secret objects, never baked into the image.
  • Probes on /-/ready: HOST stays at the image’s default 0.0.0.0 so the kubelet reaches port 3000. The startup probe allows periodSeconds × failureThreshold (five minutes above) to cover pending database migrations, workflow bundling, and OIDC discovery; raise failureThreshold if migrations take longer. Because /-/ready does not contact PostgreSQL, a database outage does not trigger restart loops.
  • Graceful stop sizing: size SHUTDOWN_TOTAL_TIMEOUT and terminationGracePeriodSeconds together using the formula in Stop the program.
  • Metrics: never publish port 9464 through this Service. To scrape Prometheus metrics safely via PodMonitor and NetworkPolicy, see Collect metrics in Kubernetes.

IdentityFlow supports 1 or 2 replicas of the same program build and workflow project against one PostgreSQL database and schema. Two replicas coordinate step execution, competing dialog answers, scheduled wakes and resumes, and takeover after a crash. More than two replicas are unsupported.

  • Always use strategy.type: Recreate: for restarts and upgrades, stop every old pod before starting its replacement. Rolling updates are unsupported because Kubernetes can keep terminating pods alive beyond the desired replica count even with maxSurge: 0. Do not manually delete a pod to force a restart: its ReplicaSet can start a replacement before the old process finishes exiting.
  • Major/schema upgrades: when upgrading across incompatible database migrations (such as to 0.4.0), scale to 0, wait for all database connections to close, then deploy the new build.
  • Startup and sessions: startup serializes database migrations, including the first start against an empty database. Sessions are stored in PostgreSQL, so sticky Ingress routing is unnecessary.
  • Crash recovery: after a crash, the surviving replica waits for the dead Engine timeout before reclaiming stranded work. The default removeEnginesOlderThan is five minutes; allow additional time for cleanup, polling, and workload.
  • Webhook rate limits apply per process: each client IP gets a burst of 8 requests refilling at 1 request/second inside each replica, and a restart resets that replica’s buckets. To enforce a shared limit across replicas, apply rate limiting at your Ingress or reverse proxy and configure the forwarded client-address headers (ADDRESS_HEADER, XFF_DEPTH).
  • Lifecycle hooks run in every replica: every pod executes each registered lifecycle.startup callback; IdentityFlow does not elect a leader for hooks. Hooks that poll or subscribe externally must tolerate multiple consumers, coordinate externally, or run with replicas: 1.
  • Identical builds and definitions: deploy the exact same program build, workflow project, dependencies, and configuration to both replicas.
  • At-least-once external effects: a completed step’s result replays from events, but a crash after an external system accepted a write and before the step completion is persisted can repeat that call. Use idempotency keys or reconciliation; running two replicas does not make external effects exactly-once.

Terminate HTTPS at your Ingress controller and route traffic to the identity-flow Service on port 3000.

If your deployment enables opt-in unauthenticated GraphQL service access, a Kubernetes NetworkPolicy alone is not enough when browsers can reach port 3000: browsers and /graphql share the same HTTP listener. Every externally reachable Ingress must strip or reject all configured service-access headers (headers.subject, headers.name, and headers.email):

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: identity-flow
annotations:
# Mandatory when auth.dangerouslyAllowUnauthenticatedServiceAccess is enabled.
# Strip every configured service-access header on externally reachable traffic.
nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header X-Workforce-Id "";
proxy_set_header X-Workforce-Name "";
proxy_set_header X-Workforce-Email "";
spec:
ingressClassName: nginx
tls:
- hosts:
- flow.example.com
secretName: identity-flow-tls
rules:
- host: flow.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: identity-flow
port:
name: http
  • Other Ingress controllers and Gateway API: if your cluster disables ingress-nginx snippet annotations or uses another controller, enforce the same strip with its native mechanism — for example a Traefik Middleware setting headers.customRequestHeaders to "" for each configured header, or a Gateway API HTTPRequestHeaderFilter (remove).
  • Keep header names synchronized: whenever you change headers.subject, headers.name, or headers.email in identity-flow.conf, update every Ingress and reverse-proxy strip rule in the same rollout.
  • Internal service traffic: route trusted in-cluster callers directly to the internal identity-flow Service (never through the public Ingress), and restrict pod ingress with a NetworkPolicy where your CNI enforces it.