# Helm chart (/self-hosting/architecture/helm-chart)

Toucan AI can be deployed easily on a Kubernetes cluster using Helm.

The chart and its images are published on our [Distr](https://distr.sh) registry: the
[deployment steps](../deployment/deployment-steps.mdx) install it.

## Variables [#variables]

This is a reference of all the values that can be overridden in your values file:

### Global Variables [#global-variables]

- `nameOverride`: Overrides the default name of the chart.
- `fullnameOverride`: Overrides the default full name of the chart.
- `extraCaCerts.configMap` or `extraCaCerts.secret`: A ConfigMap or a Secret holding your
  [internal CA bundle](../authentication-and-networking/network-requirements.mdx#internal-certificate-authority),
  which the backend and the data service trust on top of the public CAs. Set only one.
- `extraCaCerts.key`: The key holding the PEM bundle, `ca.crt` by default. Only this key is mounted.

### Frontend Variables [#frontend-variables]

- `frontend.replicaCount`: Number of replicas for the frontend deployment.
- `frontend.image.repository`: Docker image repository for the frontend.
- `frontend.image.pullPolicy`: Image pull policy for the frontend.
- `frontend.image.tag`: Docker image tag for the frontend.
- `frontend.imagePullSecrets`: Secrets for pulling the frontend image.
- `frontend.config`: Configuration values for the frontend.
- `frontend.podAnnotations`: Annotations for the frontend pods.
- `frontend.podLabels`: Labels for the frontend pods.
- `frontend.podSecurityContext`: Security context for the frontend pods.
- `frontend.securityContext`: Security context for the frontend containers.
- `frontend.service.type`: Type of the frontend service.
- `frontend.service.port`: Port of the frontend service.
- `frontend.volumes`: Additional volumes for the frontend deployment.
- `frontend.volumeMounts`: Additional volume mounts for the frontend deployment.
- `frontend.nodeSelector`: Node selector for the frontend deployment.
- `frontend.tolerations`: Tolerations for the frontend deployment.
- `frontend.affinity`: Affinity for the frontend deployment.
- `frontend.resources`: Resource requests and limits for the frontend.
- `frontend.livenessProbe`: Liveness probe for the frontend.
- `frontend.readinessProbe`: Readiness probe for the frontend.
- `frontend.autoscaling.enabled`: Whether autoscaling is enabled for the frontend.
- `frontend.autoscaling.minReplicas`: Minimum number of replicas for the frontend.
- `frontend.autoscaling.maxReplicas`: Maximum number of replicas for the frontend.
- `frontend.autoscaling.targetCPUUtilizationPercentage`: Target CPU utilization percentage for the frontend.
- `frontend.autoscaling.targetMemoryUtilizationPercentage`: Target memory utilization percentage for the frontend.

### Backend Variables [#backend-variables]

- `backend.image.repository`: Docker image repository for the backend.
- `backend.image.pullPolicy`: Image pull policy for the backend.
- `backend.image.tag`: Docker image tag for the backend.
- `backend.imagePullSecrets`: Secrets for pulling the backend image.
- `backend.config`: Configuration values for the backend.
- `backend.secrets`: Secrets for the backend.

## Web & worker [#web--worker]
- `backend.[web|worker].replicaCount`: Number of replicas for the backend deployment.
- `backend.[web|worker].podAnnotations`: Annotations for the backend pods.
- `backend.[web|worker].podLabels`: Labels for the backend pods.
- `backend.[web|worker].podSecurityContext`: Security context for the backend pods.
- `backend.[web|worker].securityContext`: Security context for the backend containers.
- `backend.[web|worker].volumes`: Additional volumes for the backend deployment.
- `backend.[web|worker].volumeMounts`: Additional volume mounts for the backend deployment.
- `backend.[web|worker].nodeSelector`: Node selector for the backend deployment.
- `backend.[web|worker].tolerations`: Tolerations for the backend deployment.
- `backend.[web|worker].affinity`: Affinity for the backend deployment.
- `backend.[web|worker].resources`: Resource requests and limits for the backend.
- `backend.[web|worker].livenessProbe`: Liveness probe for the backend.
- `backend.[web|worker].readinessProbe`: Readiness probe for the backend.
- `backend.[web|worker].autoscaling.enabled`: Whether autoscaling is enabled for the backend.
- `backend.[web|worker].autoscaling.minReplicas`: Minimum number of replicas for the backend.
- `backend.[web|worker].autoscaling.maxReplicas`: Maximum number of replicas for the backend.
- `backend.[web|worker].autoscaling.targetCPUUtilizationPercentage`: Target CPU utilization percentage for the backend.
- `backend.[web|worker].autoscaling.targetMemoryUtilizationPercentage`: Target memory utilization percentage for the backend.

### Web specific [#web-specific]
- `backend.web.service.type`: Type of the backend service.
- `backend.web.service.port`: Port of the backend service.

### Migrations [#migrations]

A Job migrates the databases whenever the backend image or its settings change, with the web settings
above (security context, resources, scheduling, env). The web and worker pods start once it has
migrated PostgreSQL. If it fails, read its logs
(`kubectl logs -l app.kubernetes.io/subcomponent=migrate`), fix the cause, then delete the Job: the
next `helm upgrade` creates it again.

## Data Service Variables [#data-service-variables]

- `dataService.auth.existingSecret`: Name of an existing Secret with the keys `data-service-auth-api-key`.
- `dataService.auth.sharedApiKey`: API key for the data service.
- `dataService.config`: Configuration values for the data service.

### Ingress Variables [#ingress-variables]

- `ingress.enabled`: Whether ingress is enabled.
- `ingress.className`: Ingress class name.
- `ingress.annotations`: Annotations for the ingress.
- `ingress.hosts`: Hosts for the ingress.
- `ingress.tls`: TLS configuration for the ingress.

### Service Account Variables [#service-account-variables]

- `serviceAccount.create`: Whether to create a service account.
- `serviceAccount.automount`: Whether to automount the service account token.
- `serviceAccount.annotations`: Annotations for the service account.
- `serviceAccount.name`: Name of the service account.

### PostgreSQL Variables [#postgresql-variables]

- `postgresql.enabled`: Whether PostgreSQL is enabled.

See [the PostgreSQL chart parameter](https://github.com/bitnami/charts/tree/main/bitnami/postgresql#parameters) for other parameters.

Main ones are:
- `postgresql.fullname`: Full name of the PostgreSQL deployment.
- `postgresql.auth.postgresPassword`: Password for the PostgreSQL admin user.
- `postgresql.auth.username`: Username for the PostgreSQL user.
- `postgresql.auth.password`: Password for the PostgreSQL user.
- `postgresql.auth.database`: Database name for PostgreSQL.
- `postgresql.service.ports.postgresql`: Port for PostgreSQL.
- `postgresql.primary.initdb.scriptsConfigMap`: ConfigMap for PostgreSQL init scripts.


### Redis Variables [#redis-variables]

- `redis.enabled`: Whether Redis is enabled.
See [the Redis chart parameter](https://github.com/bitnami/charts/tree/main/bitnami/redis#parameters) for other parameters.

Note: auto-configuration of the REDIS_URL config parameter for the backend is only supported when `architecture` is `standalone`.

### Object Storage Variables [#object-storage-variables]

The backend stores files in an S3-compatible bucket.

- `objectStorage.enabled`: Whether to run a single-node [Garage](https://garagehq.deuxfleurs.fr/) in the release, which the backend is then configured for. Good for evaluation; in production, disable it and use a managed bucket.
- `objectStorage.auth`: Required, the chart has no default. Either `existingSecret`, a Secret with the keys `object-storage-access-key-id`, `object-storage-secret-access-key` and `object-storage-rpc-secret`, or `accessKeyId` (generate it with `echo GK$(openssl rand -hex 12)`), `secretAccessKey` and `rpcSecret` (`openssl rand -hex 32` each).
- `objectStorage.persistence.enabled` and `objectStorage.persistence.spec`: Whether its data is kept on a volume claim, and that claim's spec.
- `objectStorage.networkPolicy`: Who may reach it (the backend only, by default) and where it may connect (only DNS, by default).

With a managed bucket, set `OBJECT_STORAGE_ENDPOINT`, `OBJECT_STORAGE_BUCKET` and `OBJECT_STORAGE_REGION` in `backend.config`, and `OBJECT_STORAGE_ACCESS_KEY_ID` and `OBJECT_STORAGE_SECRET_ACCESS_KEY` from a secret.

### AI Crew Variables [#ai-crew-variables]

The AI Crew runs each request in a Kubernetes Job of its own. The backend worker creates these Jobs in
the release namespace. The AI Crew is off by default.

- `backend.aiCrew.enabled`: Whether to run the AI Crew. The worker then gets its own service account,
  with a Role that lets it create and delete Jobs, create Secrets, list pods and read their logs. Your
  Helm user, or Argo CD, must be allowed to create Roles and RoleBindings.
- `backend.aiCrew.image`: The image of the runs. Its tag defaults to the backend's. Set `digest` to
  pull it by digest.
- `backend.aiCrew.runtimeClassName`: A sandboxing runtime for the runs, such as
  [gVisor](https://gvisor.dev/). When empty, the cluster default is used.
- `backend.aiCrew.podLabels` and `backend.aiCrew.podAnnotations`: Labels and annotations for the runs'
  pods.
- `backend.aiCrew.podSecurityContext` and `backend.aiCrew.securityContext`: Security contexts of the
  runs' pods and containers. The root filesystem is read-only. Only `/tmp` and the home folder are
  writable.
- `backend.aiCrew.env`: Additional environment variables of the runs, such as `HTTPS_PROXY` if your
  cluster reaches the internet through a proxy.
- `backend.aiCrew.volumes` and `backend.aiCrew.volumeMounts`: Additional volumes of the runs, such as
  an internal CA bundle.
- `backend.aiCrew.resources`, `backend.aiCrew.nodeSelector`, `backend.aiCrew.tolerations`,
  `backend.aiCrew.affinity` and `backend.aiCrew.priorityClassName`: Resources and scheduling of the
  runs.
- `backend.aiCrew.networkPolicy.enabled`: Whether to restrict the runs' network. They accept no
  connection, and they can only reach DNS and public addresses. They need your LLM provider and the
  app's public URL (`PUBLIC_URL`).
- `backend.aiCrew.networkPolicy.extraEgress`: Additional egress rules for the runs. Add one if your
  LLM endpoint or `PUBLIC_URL` resolves to a private address.

:::info
If you set `backend.worker.networkPolicy.allowExternalEgress` to `false`, add a
`backend.worker.networkPolicy.extraEgress` rule to your cluster's API server. The worker calls it to
run the AI Crew's Jobs.
:::

### Extra Manifests [#extra-manifests]

- `extraManifests`: Additional Kubernetes manifests to deploy.
