|
| 1 | +# Utopia Helm chart |
| 2 | + |
| 3 | +This chart is community-maintained. The supported way to run Utopia is still |
| 4 | +`docker-compose.yml` at the root of the repo, and this chart follows it: the |
| 5 | +image tag defaults to the chart's `appVersion`, which CI keeps equal to the |
| 6 | +compose default. |
| 7 | + |
| 8 | +It runs one replica with a `Recreate` rollout on a single `ReadWriteOnce` |
| 9 | +volume, because the data directory (original files, full-text index) and the |
| 10 | +worker belong to one process. Everything optional is off by default. |
| 11 | + |
| 12 | +## With your own Postgres |
| 13 | + |
| 14 | +You need Postgres 16 or newer with pgvector. Before the first start, create |
| 15 | +the owner, the database, the extension and the `utopia_app` runtime role as a |
| 16 | +superuser. This is what `docker/init-app-role.sh` does for compose: |
| 17 | + |
| 18 | +```sql |
| 19 | +CREATE ROLE utopia LOGIN PASSWORD '<owner password>'; |
| 20 | +CREATE DATABASE utopia OWNER utopia; |
| 21 | +\c utopia |
| 22 | +CREATE EXTENSION IF NOT EXISTS vector; |
| 23 | +CREATE ROLE utopia_app LOGIN PASSWORD '<app password>'; |
| 24 | +GRANT CONNECT ON DATABASE utopia TO utopia_app; |
| 25 | +``` |
| 26 | + |
| 27 | +The migrations run as the owner and grant `utopia_app` the tables it needs, |
| 28 | +so the role must exist before the first start. The app then runs as |
| 29 | +`utopia_app`, which can append to the audit log but not change it. |
| 30 | + |
| 31 | +```bash |
| 32 | +kubectl create secret generic utopia-db \ |
| 33 | + --from-literal=database-url='postgres://utopia_app:<app password>@<host>:5432/utopia' \ |
| 34 | + --from-literal=migration-url='postgres://utopia:<owner password>@<host>:5432/utopia' |
| 35 | +helm install utopia deploy/chart --set database.existingSecret=utopia-db |
| 36 | +``` |
| 37 | + |
| 38 | +To skip the runtime role, leave out `migration-url` and point `database-url` |
| 39 | +at the owner. `database.url` and `database.migrationUrl` also work instead of |
| 40 | +a Secret you create, and the chart then writes the Secret itself. |
| 41 | + |
| 42 | +## With CloudNativePG |
| 43 | + |
| 44 | +With the [CloudNativePG](https://cloudnative-pg.io) operator installed, the |
| 45 | +chart can create a one-instance cluster with pgvector and `utopia_app`, and |
| 46 | +generate its password: |
| 47 | + |
| 48 | +```bash |
| 49 | +helm install utopia deploy/chart --set database.mode=cloudnativepg |
| 50 | +``` |
| 51 | + |
| 52 | +The generated password survives upgrades only through Helm's `lookup`, which |
| 53 | +returns nothing under `helm template`, `--dry-run`, Argo CD and Flux. There it |
| 54 | +would change on every render, so create the Secret yourself and name it: |
| 55 | + |
| 56 | +```bash |
| 57 | +kubectl create secret generic utopia-db-role --type=kubernetes.io/basic-auth \ |
| 58 | + --from-literal=username=utopia_app --from-literal=password="$(openssl rand -hex 24)" |
| 59 | +helm install utopia deploy/chart --set database.mode=cloudnativepg \ |
| 60 | + --set database.cloudnativepg.existingSecret=utopia-db-role |
| 61 | +``` |
| 62 | + |
| 63 | +The default image is a CloudNativePG `standard` image, which ships pgvector. |
| 64 | +If you set `database.cloudnativepg.image`, keep a `-standard-` tag. |
| 65 | + |
| 66 | +## Keys |
| 67 | + |
| 68 | +Without other settings the app keeps its credential key in `secret.key` on the |
| 69 | +data volume and its JWT secret in the database, so back up the volume together |
| 70 | +with the database. To hold them in Kubernetes instead, set `keys.existingSecret` to |
| 71 | +a Secret with the keys `secret-key` and `jwt-secret`. |
| 72 | + |
| 73 | +## Moving from compose |
| 74 | + |
| 75 | +The pod runs as uid 1000, while compose runs the app as root, so a `data` |
| 76 | +directory copied from compose is owned by root and the app cannot write to it. |
| 77 | +Run `sudo chown -R 1000:1000 data` before copying it, and copy with a tool that |
| 78 | +keeps the owner, such as `tar -p` or `rsync -a`. Copy the database with |
| 79 | +`pg_dump` and `pg_restore` as usual. |
| 80 | + |
| 81 | +## Reaching it |
| 82 | + |
| 83 | +`kubectl port-forward svc/utopia 1516:80` opens it on http://localhost:1516. |
| 84 | +For an Ingress, set `ingress.enabled=true` and `ingress.host`, plus |
| 85 | +`ingress.tlsSecretName` for TLS, which also sets `UTOPIA_COOKIE_SECURE=true`. |
| 86 | +If TLS ends somewhere else, set `ingress.cookieSecure` to `true` or `false` |
| 87 | +yourself. Uploads go up to 100 MB, so the controller |
| 88 | +must allow request bodies that large. Other app settings, such as single |
| 89 | +sign-on, go in `extraEnv`, with the names from `.env.example`. |
0 commit comments