Deploy on Kubernetes
Kubernetes can run more than one copy of a service on different machines. The manifests in this guide run two copies of the web app and of the API, and one copy of everything else: the worker, the agent, its MCP server, MySQL and Valkey. If the machine that runs a single copy fails, that part is down until Kubernetes starts it again on another machine. When that is not enough, use managed services for MySQL and Valkey, and run several replicas of the agent as Run the agent on several replicas describes. FINOS Workspace does not ship a Helm chart. This guide gives plain manifests for every part, in the order you apply them. Use them as they are, or turn them into Kustomize overlays or a chart of your own.
This guide follows Production setup, so read that page first.
What you need
- A cluster, and
kubectlthat can reach it. - An ingress controller, and a TLS certificate for three names on the same domain. This guide uses
workspace.example.comfor the web app,api.workspace.example.comfor the API andagent.workspace.example.comfor the agent. - The four images. The cluster pulls them from Docker Hub as
finos/workspace-backend,finos/workspace-web,finos/workspace-agentandfinos/workspace-agent-mcp. Set<version>in the manifests below to the tag of a release, including its leadingv, and pin it rather than usinglatest, which moves to every new release, pre-releases included. The released images are built forlinux/amd64, so run them on x86-64 nodes. To use images of your own, build and push them to a registry that the cluster can pull from, and put that registry in front of the names. - The secrets from Production setup, and an API key for the agent's model.
- MySQL and Valkey. Use your platform's managed services, or run them in the cluster with the manifests in Run MySQL and Valkey in the cluster.
- A place for uploaded files that every API and worker pod can reach: a bucket, or a volume that pods on different nodes can mount at the same time.
What runs
| Workload | Kind | Port | Probes | User | Replicas | Memory to start with |
|---|---|---|---|---|---|---|
| Web app | Deployment | 8080 | /healthz | 101 | Two or more | Request 64 MiB, limit 256 MiB |
| API | Deployment | 8000 | /healthz | 1000 | Two or more | Request 512 MiB, limit 2 GiB |
| Worker | Deployment | None | None | 1000 | One | Request 512 MiB, limit 1 GiB |
| Agent | Deployment | 7777 | Liveness /status, readiness /ready | 1000 | One, or more with Valkey | Request 512 MiB, limit 4 GiB |
| Agent MCP server | Deployment | 8787 | / | 1000 | One, or more with Valkey | Request 256 MiB, limit 4 GiB |
| Init step | Job | None | None | 1000 | One run per release | Request 512 MiB |
The memory figures are starting points. Watch what each workload uses, and give the agent enough for the largest files your users attach.
Everything goes into one namespace:
kubectl create namespace finos-workspace
The manifests leave the namespace out, and the commands below pass -n finos-workspace.
Create the secrets
Put the secrets of the API and the worker into a file called backend.env. Both database passwords are the password of the database user workspace:
JWT_SECRET=<JWT_SECRET>
WORKSPACE_AES_KEY=<WORKSPACE_AES_KEY>
LOCAL_STORAGE_SECRET_KEY=<LOCAL_STORAGE_SECRET_KEY>
REDIS_PASS=
WRITE_DB_PASSWORD=<the database password>
READ_DB_PASSWORD=<the database password>
REDIS_PASS is empty because the Valkey in this guide has no password. Keep the line anyway: the API does not start when the variable is missing. If you run MySQL in the cluster, put its root password into mysql.env:
MYSQL_ROOT_PASSWORD=<a random password>
Turn both files into Secrets:
kubectl -n finos-workspace create secret generic workspace-backend --from-env-file=backend.env
kubectl -n finos-workspace create secret generic mysql --from-env-file=mysql.env
The agent's Secret comes later, because the API creates its metering token.
Write the settings
Save the settings as config.yaml. Change the three addresses to yours, and set DEFAULT_MODEL:
apiVersion: v1
kind: ConfigMap
metadata:
name: workspace-backend
data:
MODE: production
DATABASE_TYPE: mysql
DB_HOST: mysql
DB_PORT: "3306"
DB_NAME: workspace
WRITE_DB_USER: workspace
READ_DB_USER: workspace
REDIS_HOST: valkey
APPURL: https://workspace.example.com
FRONTENDURL: https://workspace.example.com
SELFURL: https://api.workspace.example.com
BACKEND_CORS_ORIGINS: https://workspace.example.com
FOLDER_STORAGE_PATH: /opt/code/local_storage
DEFAULT_MCP_SERVERS: '[{"id": "agent-tools", "name": "Agent Tools", "url": "http://agent-mcp:8787/mcp"}]'
---
apiVersion: v1
kind: ConfigMap
metadata:
name: workspace-agent
data:
DEFAULT_MODEL: openai:<model>
WORKSPACE_API_URL: http://api:8000
WORKSPACE_ORIGIN: https://workspace.example.com
WORKSPACE_PUBLIC_URL: https://api.workspace.example.com
REDIS_URL: redis://valkey:6379
AGENT_CORS_ORIGINS: https://workspace.example.com
---
apiVersion: v1
kind: ConfigMap
metadata:
name: workspace-init
data:
config.toml: |
[entity]
name = "Example Bank"
[[admins]]
email = "admin@example.com"
first_name = "Ada"
last_name = "Admin"
DB_HOSTandREDIS_HOSTname the Services from Run MySQL and Valkey in the cluster. With managed services, put their addresses here instead, and their passwords intobackend.env.DEFAULT_MCP_SERVERSgives the API the address of the agent's MCP server, which stays inside the cluster.DEFAULT_MODELis written<provider>:<model>. Pick the providers lists the providers and their keys.config.tomlnames the first organization and its administrators, which the init step creates. It finds the organization by its name, so changing the name later creates a second organization.
Pods read the ConfigMaps when they start. After you change one, restart the pods that use it, for example with kubectl -n finos-workspace rollout restart deployment/api deployment/worker.
Run MySQL and Valkey in the cluster
Skip this step when you use managed services, and apply config.yaml alone. Otherwise save this as data.yaml:
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
clusterIP: None
selector:
app: mysql
ports:
- name: mysql
port: 3306
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql
spec:
serviceName: mysql
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:8.0
args: ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql
key: MYSQL_ROOT_PASSWORD
- name: MYSQL_DATABASE
value: workspace
- name: MYSQL_USER
value: workspace
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: workspace-backend
key: WRITE_DB_PASSWORD
ports:
- name: mysql
containerPort: 3306
readinessProbe:
exec:
command: ["sh", "-c", "mysqladmin ping -h 127.0.0.1 -u root -p\"$MYSQL_ROOT_PASSWORD\" --silent"]
periodSeconds: 5
volumeMounts:
- name: data
mountPath: /var/lib/mysql
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10Gi
---
apiVersion: v1
kind: Service
metadata:
name: valkey
spec:
clusterIP: None
selector:
app: valkey
ports:
- name: valkey
port: 6379
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: valkey
spec:
serviceName: valkey
replicas: 1
selector:
matchLabels:
app: valkey
template:
metadata:
labels:
app: valkey
spec:
containers:
- name: valkey
image: valkey/valkey:9.1.2-alpine
args: ["valkey-server", "--save", "20", "1", "--loglevel", "warning"]
ports:
- name: valkey
containerPort: 6379
readinessProbe:
exec:
command: ["valkey-cli", "ping"]
periodSeconds: 5
volumeMounts:
- name: data
mountPath: /data
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
MySQL takes the password of the user workspace from the backend's Secret, so the two always match. MySQL reads its passwords once, on its very first start, when the volume is empty, the same as in the Compose guide.
Apply the settings and the data services, and wait until both are ready:
kubectl -n finos-workspace apply -f config.yaml -f data.yaml
kubectl -n finos-workspace rollout status statefulset/mysql
kubectl -n finos-workspace rollout status statefulset/valkey
Run the init step
The backend image has no shell, so the Job starts a short Python program that runs the three actions. Save this as init-job.yaml:
apiVersion: batch/v1
kind: Job
metadata:
name: workspace-init
spec:
backoffLimit: 2
template:
spec:
restartPolicy: Never
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: init
image: finos/workspace-backend:<version>
command:
- python
- -c
- |
import pathlib, subprocess, sys
pathlib.Path("user_create.json").write_text("{}")
subprocess.run([sys.executable, "-m", "alembic", "upgrade", "head"], check=True)
subprocess.run([sys.executable, "-m", "scripts.init_users"], check=True)
print(pathlib.Path("user_create.json").read_text())
envFrom:
- configMapRef:
name: workspace-backend
- secretRef:
name: workspace-backend
resources:
requests:
memory: 512Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumeMounts:
- name: config
mountPath: /opt/code/scripts/cfgs/config.toml
subPath: config.toml
readOnly: true
volumes:
- name: config
configMap:
name: workspace-init
Run it, wait until it completes and read its log:
kubectl -n finos-workspace apply -f init-job.yaml
kubectl -n finos-workspace wait --for=condition=complete job/workspace-init --timeout=5m
kubectl -n finos-workspace logs job/workspace-init
The log ends with the id of the role that new people get, for example:
{
"permissions_uuid": "0497efcd-31bf-4538-87ea-22f01290b6f3"
}
The API and the worker cannot see the Job's files, so they need that id as the setting DEFAULT_USER_MAPPING. Add it under data of the workspace-backend ConfigMap in config.yaml, with your own id, and apply the file again:
DEFAULT_USER_MAPPING: "0497efcd-31bf-4538-87ea-22f01290b6f3"
kubectl -n finos-workspace apply -f config.yaml
The id stays the same when the Job runs again later, because a run that finds everything in place changes nothing. If the Job fails, its log names the reason, with the same messages as in When the init step fails.
Start the API and the worker
Save this as backend.yaml:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: storage
spec:
accessModes: ["ReadWriteMany"]
storageClassName: <a storage class that supports ReadWriteMany>
resources:
requests:
storage: 20Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: api
spec:
replicas: 2
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: api
image: finos/workspace-backend:<version>
ports:
- name: http
containerPort: 8000
envFrom:
- configMapRef:
name: workspace-backend
- secretRef:
name: workspace-backend
startupProbe:
httpGet:
path: /healthz
port: http
periodSeconds: 5
failureThreshold: 60
readinessProbe:
httpGet:
path: /healthz
port: http
livenessProbe:
httpGet:
path: /healthz
port: http
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
memory: 2Gi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumeMounts:
- name: storage
mountPath: /opt/code/local_storage
volumes:
- name: storage
persistentVolumeClaim:
claimName: storage
---
apiVersion: v1
kind: Service
metadata:
name: api
spec:
selector:
app: api
ports:
- name: http
port: 8000
targetPort: http
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: worker
spec:
replicas: 1
selector:
matchLabels:
app: worker
template:
metadata:
labels:
app: worker
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: worker
image: finos/workspace-backend:<version>
command: ["python", "base_workers.py"]
envFrom:
- configMapRef:
name: workspace-backend
- secretRef:
name: workspace-backend
resources:
requests:
cpu: 100m
memory: 512Mi
limits:
memory: 1Gi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumeMounts:
- name: storage
mountPath: /opt/code/local_storage
volumes:
- name: storage
persistentVolumeClaim:
claimName: storage
kubectl -n finos-workspace apply -f backend.yaml
kubectl -n finos-workspace rollout status deployment/api
kubectl -n finos-workspace rollout status deployment/worker
- The volume
storageholds the uploaded files, and every API and worker pod mounts it. When the pods run on more than one node, it must allowReadWriteMany, so setstorageClassNameto a class that supports it, such as one backed by Amazon EFS, Azure Files or Google Filestore, or by an NFS server. WithoutstorageClassName, Kubernetes uses the default class. The default class of many clusters, and the one of kind, offersReadWriteOnceonly, and then the claim staysPending: on kind, its event reads "NodePath only supports ReadWriteOnce and ReadWriteOncePod (1.22+) access modes". On a single node,ReadWriteOnceworks. fsGroup: 1000asks Kubernetes to make the volume writable for the user 1000. ManyReadWriteManyvolumes ignore it: by default, Kubernetes appliesfsGroupto a volume of a CSI driver only when the volume also allowsReadWriteOnce. On such a volume, a pod running as the user 1000 fails withPermission deniedwhen it writes a file, until you set the owner of the volume's directory to the user 1000 in the storage itself.- To keep the files in a bucket instead, set the storage settings from Choose where files are stored and remove the volume.
- The startup probe gives the API five minutes, because each API pod runs the database migrations before it serves.
Start the agent
Create the agent's metering token in an API pod:
kubectl -n finos-workspace exec deploy/api -- python -m scripts.create_metering_token
It prints the token, then the date on which it expires, a year from now. Put the token into agent.env with the agent's other secrets. This example uses OpenAI:
OPENAI_API_KEY=<your OpenAI API key>
AGENT_SCOPE_SECRET=<AGENT_SCOPE_SECRET>
AGENT_METERING_TOKEN=<the token>
For another provider, set its own key instead of OPENAI_API_KEY, or for Ollama OLLAMA_BASE_URL. Pick the providers lists them.
Save the agent and its MCP server as agent.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: agent
spec:
replicas: 1
selector:
matchLabels:
app: agent
template:
metadata:
labels:
app: agent
spec:
shareProcessNamespace: true
terminationGracePeriodSeconds: 30
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: agent
image: finos/workspace-agent:<version>
ports:
- name: http
containerPort: 7777
envFrom:
- configMapRef:
name: workspace-agent
- secretRef:
name: workspace-agent
livenessProbe:
httpGet:
path: /status
port: http
readinessProbe:
httpGet:
path: /ready
port: http
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
memory: 4Gi
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: agent
spec:
selector:
app: agent
ports:
- name: http
port: 7777
targetPort: http
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: agent-mcp
spec:
replicas: 1
selector:
matchLabels:
app: agent-mcp
template:
metadata:
labels:
app: agent-mcp
spec:
shareProcessNamespace: true
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: agent-mcp
image: finos/workspace-agent-mcp:<version>
ports:
- name: http
containerPort: 8787
envFrom:
- configMapRef:
name: workspace-agent
- secretRef:
name: workspace-agent
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
memory: 4Gi
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: agent-mcp
spec:
selector:
app: agent-mcp
ports:
- name: http
port: 8787
targetPort: http
kubectl -n finos-workspace create secret generic workspace-agent --from-env-file=agent.env
kubectl -n finos-workspace apply -f agent.yaml
kubectl -n finos-workspace rollout status deployment/agent
kubectl -n finos-workspace rollout status deployment/agent-mcp
- Both run with a read-only root file system and a writable
/tmp. shareProcessNamespace: truelets the pod's pause process clean up the child processes that the agent starts.terminationGracePeriodSecondsmust be at leastAGENT_SHUTDOWN_GRACE_SECONDS, which is 25 seconds by default, so that the agent can finish the answers it is working on when the pod stops.- The readiness probe
/readyanswers 503 while the agent cannot reach the API.
If every question fails with status 503 and the message "The FINOS Workspace API is not available" while the agent pod is ready, read its log with kubectl -n finos-workspace logs deploy/agent. The line "The FINOS Workspace API refused this agent's metering token" means that the token has expired, or that JWT_SECRET changed after you created it. Create a new token, update the Secret workspace-agent and restart the agent.
Start the web app and expose everything
Save the web app as web.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 2
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
securityContext:
runAsNonRoot: true
runAsUser: 101
runAsGroup: 101
seccompProfile:
type: RuntimeDefault
containers:
- name: web
image: finos/workspace-web:<version>
ports:
- name: http
containerPort: 8080
env:
- name: BACKEND_URL
value: https://api.workspace.example.com
- name: AI_API_URL
value: https://agent.workspace.example.com
- name: AI_COPILOT_ENABLED
value: "true"
readinessProbe:
httpGet:
path: /healthz
port: http
livenessProbe:
httpGet:
path: /healthz
port: http
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
memory: 256Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
---
apiVersion: v1
kind: Service
metadata:
name: web
spec:
selector:
app: web
ports:
- name: http
port: 8080
targetPort: http
Save the Ingress as ingress.yaml, with your ingress controller's class in ingressClassName:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: workspace
spec:
ingressClassName: <ingress class>
tls:
- hosts:
- workspace.example.com
- api.workspace.example.com
- agent.workspace.example.com
secretName: workspace-tls
rules:
- host: workspace.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web
port:
name: http
- host: api.workspace.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api
port:
name: http
- host: agent.workspace.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: agent
port:
name: http
Put the certificate for the three names into the Secret workspace-tls, or let your certificate manager create it. Then apply both files:
kubectl -n finos-workspace create secret tls workspace-tls --cert=tls.crt --key=tls.key
kubectl -n finos-workspace apply -f web.yaml -f ingress.yaml
kubectl -n finos-workspace rollout status deployment/web
The agent streams its answers, so set the idle timeout of your ingress controller for the agent's name to at least the longest model call, as What the load balancer and the platform allow describes. Each controller sets it with its own annotation or policy.
Set the request size limit too. The web app lets people attach files of up to 25 MiB, and the agent accepts a request of up to AGENT_MAX_BODY_MB megabytes, 64 by default. ingress-nginx refuses a request body of more than 1 MiB with status 413 unless the Ingress has the annotation nginx.ingress.kubernetes.io/proxy-body-size, for example with the value 64m. Other controllers have a setting of their own.
The API counts its rate limits per client address and reads that address from X-Forwarded-For, so make sure your ingress controller passes it on, as What your platform needs to provide describes.
Give the administrator a password
kubectl -n finos-workspace exec -it deploy/api -- python -m scripts.init_users --new-password admin@example.com
It asks for the password twice and does not show what you type. The password needs at least 8 characters, with an uppercase letter, a lowercase letter, a number and a special character, and no spaces. The underscore does not count as a special character. Then go through the checks in Production setup.
Upgrade
-
Back up the database, as Back up and restore shows.
-
Change the version in the image names in
init-job.yaml,backend.yaml,agent.yamlandweb.yaml. -
Run the init step with the new image. A Job cannot be changed once it exists, so delete the old one first:
kubectl -n finos-workspace delete job workspace-initkubectl -n finos-workspace apply -f init-job.yamlkubectl -n finos-workspace wait --for=condition=complete job/workspace-init --timeout=5m -
Roll out the API and the worker, then the agent and the web app:
kubectl -n finos-workspace apply -f backend.yamlkubectl -n finos-workspace rollout status deployment/apikubectl -n finos-workspace apply -f agent.yaml -f web.yaml
Back up and restore
With a managed database, use its backups. With the MySQL from this guide, these commands write the database to workspace.sql and load it back:
kubectl -n finos-workspace exec mysql-0 -- sh -c 'exec mysqldump --single-transaction -u root -p"$MYSQL_ROOT_PASSWORD" workspace' > workspace.sql
kubectl -n finos-workspace exec -i mysql-0 -- sh -c 'exec mysql -u root -p"$MYSQL_ROOT_PASSWORD" workspace' < workspace.sql
MySQL warns that a password on the command line can be insecure. The password stays inside the pod, and the warning does not end up in the file.
The uploaded files are not in the database. With a bucket, use the versioning and backups of your provider. With the volume storage, use the snapshots of your storage.
Keep backend.env, and the settings and manifests that you applied, safe away from the cluster too: without the WORKSPACE_AES_KEY in backend.env, the secrets stored in the database cannot be read.
Change a database password
Change the password in MySQL first, then in the Secret, then restart the pods that read the Secret. MySQL reads the passwords of its Secret only on its very first start, so a changed Secret alone leaves the API with a password that MySQL does not know.
With the MySQL of this guide, open a MySQL session as the root user:
kubectl -n finos-workspace exec -it mysql-0 -- sh -c 'exec mysql -u root -p"$MYSQL_ROOT_PASSWORD"'
At the mysql> prompt, change the password of the user workspace:
ALTER USER 'workspace'@'%' IDENTIFIED BY '<the new password>';
Put the new password into WRITE_DB_PASSWORD and READ_DB_PASSWORD in backend.env, update the Secret from the file and restart the API and the worker:
kubectl -n finos-workspace create secret generic workspace-backend --from-env-file=backend.env --dry-run=client -o yaml | kubectl -n finos-workspace replace -f -
kubectl -n finos-workspace rollout restart deployment/api deployment/worker
kubectl -n finos-workspace rollout status deployment/api