Installing on Kubernetes

Deploy Structam with the kustomization: two serve replicas, an autoscaled worker Deployment, a migration Job, probes, ingress and the first administrator.

On this page

Status. The manifests were rendered with kubectl kustomize only. Not yet run: against a cluster, including the HorizontalPodAutoscaler and the KEDA ScaledObject.

deploy/kubernetes is a kustomization:

  • two structam serve replicas (Deployment structam-serve, Service structam, a PodDisruptionBudget);
  • a structam worker Deployment with a PodDisruptionBudget and a HorizontalPodAutoscaler on the ingest queue depth (1 to 8 pods, scaling);
  • a migration Job and the shared ConfigMap (structam-config).

PostgreSQL is not part of it: use CloudNativePG, a Patroni cluster or a managed service, and give Structam its writer endpoint or a multi-host connection string.

Install

kubectl create namespace structam
umask 077
openssl rand -base64 32 > secret_key                 # keep a copy outside the cluster
echo 'postgres://structam:PASSWORD@structam-db-rw:5432/structam?sslmode=verify-full' > database_url
kubectl -n structam create secret generic structam-secrets --from-file=secret_key --from-file=database_url
# Edit deploy/kubernetes/kustomization.yaml (images: your registry and tag) and configmap.yaml
# (STRUCTAM_PUBLIC_URL, STRUCTAM_TRUSTED_PROXIES), then:
kubectl apply -k deploy/kubernetes
kubectl -n structam wait --for=condition=complete job/structam-migrate --timeout=30m
kubectl -n structam rollout status deploy/structam-serve

Push the image KazLabs provided to your own registry and name it under images: in kustomization.yaml. The ConfigMap sets STRUCTAM_MIGRATE=off, so only the Job migrates the schema; other settings (configuration reference) go in the ConfigMap, and secrets in the Secret as file forms.

Ingress and probes

Put an Ingress or a load balancer in front of the structam Service. deploy/kubernetes/ingress.example.yaml shows ingress-nginx: TLS, no response buffering, and hour-long read timeouts for the agent WebSocket.

  • Pods probe /livez for liveness (it never touches the database) and /readyz for readiness (primary reachable, schema compatible, not draining).
  • Serve pods sleep 5 s in preStop, so the endpoint is removed before the drain starts; the sleep action needs Kubernetes 1.30 or newer. Serve pods have 60 s to stop, worker pods 45 s.
  • Serve pods roll with maxUnavailable: 0.

The first administrator

There is no bootstrap password in the manifests. Create the first administrator from a pod:

kubectl -n structam exec deploy/structam-serve -- structam user create -username admin -admin

It prints a temporary password, which must be changed at the first sign-in.

Pod security

Pods run as a non-root user with a read-only root file system, drop every capability and disallow privilege escalation. The server writes nothing to disk.

Database connections

The manifests set STRUCTAM_INGEST_WORKERS_MAX to 4 on serve pods and 8 on worker pods, because Go sizes the default from the CPU limit, not the request. With 2 serve pods and at most 8 worker pods the cluster uses up to 216 database connections, and up to 284 during a rolling update. Keep PostgreSQL's max_connections above that (scaling).

Upgrading

Delete the finished Job, set the new image tag, apply, and wait for the migration before the Deployments roll:

kubectl -n structam delete job structam-migrate --ignore-not-found
kubectl apply -k deploy/kubernetes                      # images: newTag set to the new release
kubectl -n structam wait --for=condition=complete job/structam-migrate --timeout=30m

See upgrading for when a release raises the schema's compatibility floor.

Questions the docs do not answer?

Ask the people who build Structam. Installation media and licences come from KazLabs.

Talk to us