Kubernetes with Helm
Install Spica on Kubernetes with the official Helm chart, configure database, secrets, ingress and storage, and scale and upgrade it.
The official Helm chart installs the API, the panel, a MongoDB replica set or PostgreSQL, an ingress, secrets and a migration job that runs before upgrades.
Install
helm repo add spica https://spica-charts.storage.googleapis.com
helm repo update
helm search repo spicaCreate a values file:
application:
publicHost: https://admin.example.com
masterKey: "<a long random value>"
defaultPassword: "<a strong admin password>"
database:
type: mongodb
replicas: 3
storageSize: 20Gi
spicaUsername: spica
spicaPassword: "<database password>"
rootUsername: root
rootPassword: "<database root password>"
replicaAuthKey: "<a long random value>"
ingress:
ingressClassName: nginx
hosts:
- name: admin.example.com
application: /
api: /api
tls:
- hosts: [admin.example.com]
secretName: admin-example-com-tlshelm install spica spica/spica --namespace spica --create-namespace -f values.yaml --version 0.22.1When the release is ready, the chart prints where the panel is and the credentials of the default identity:
Web Controller is open at https://admin.example.com/
Credentials are:
# Username: spica
# Password: <defaultPassword>How it fits together
| Resource | Purpose |
|---|---|
StatefulSet or Deployment <release>-application | The API (port 4300, gRPC 50051) and the panel, as two containers of one pod. |
Service <release>-application | Exposes the panel and the API inside the cluster. |
StatefulSet <release>-database | MongoDB nodes, or a single PostgreSQL node. |
Job <release>-replication-controller | Initializes the MongoDB replica set. |
Ingress <release>-application | Routes application paths to the panel and api paths to the API. |
Secrets | The master key or individual secrets, and database credentials. |
Job <release>-migrate | Runs on upgrades only, as a pre-upgrade hook that migrates stored data before new pods start. |
The API's public URL is application.publicHost + application.apiBaseUrl (/api/ by default). Probes use /status/live and /status/ready.
Secrets
Provide either application.masterKey, from which every secret is derived, or all individual secrets: secret, bucketDataHashSecret, bucketDataEncryptionSecret, secretModuleEncryptionSecret, userVerificationHashSecret, userProviderEncryptionSecret, userProviderHashSecret and refreshTokenHashSecret. Individual values override the derived ones.
Secrets are stored in a Kubernetes Secret and reused on upgrades, so you don't have to pass them again. Rendering fails with a clear message when something is missing:
Error: execution error at (spica/templates/applicationsecrets.yaml:35:36): masterKey is absent: .Values.application.secret is requiredChoosing the database
database:
type: postgresql
storageSize: 20Gi
spicaUsername: spica
spicaPassword: "<password>"
rootUsername: postgres
rootPassword: "<password>"PostgreSQL runs as a single node and ignores database.replicas. The image (database.postgresImage, spicaengine/postgres by default) must include pg_cron. The engine can't be changed after installation. See MongoDB and PostgreSQL.
Passing API options
Any API option can be added with application.args:
application:
args:
- --bucket-cache=true
- --function-timeout=120
- --access-logs=true
responseHeaders:
X-Frame-Options: DENY
Strict-Transport-Security: max-age=31536000The chart sets the port, database, public URL, persistent path, default password and replication options itself.
Storage and scaling
application.diskAccessMode decides how /data (uploaded files and function sources) is stored:
| Value | Workload | /data | Use when |
|---|---|---|---|
ReadWriteOnce (default) | StatefulSet | A volume per pod | One replica. |
ReadWriteMany | Deployment | One shared volume | Several replicas with an RWX storage class (NFS, EFS, Filestore). |
None | Deployment | emptyDir, lost on restart | Several replicas with S3 or GCS for files and function sources. |
A horizontally scaled setup with object storage:
application:
replicas: 3
diskAccessMode: None
serviceAccountName: spica
args:
- --storage-strategy=awss3
- --awss3-bucket-name=acme-spica-files
- --function-asset-storage-strategy=awss3
- --function-asset-awss3-bucket-name=acme-spica-functionsWith more than one replica, the chart turns on --replication automatically. On EKS, give the service account an IAM role (IRSA) and leave the credential file options out. The AWS SDK picks the role up.
Ingress
ingress:
ingressClassName: nginx
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: 35M
nginx.ingress.kubernetes.io/client-body-buffer-size: 35m
nginx.ingress.kubernetes.io/rewrite-target: /$1
hosts:
- name: admin.example.com
application: /
api: /api
tls:
- hosts: [admin.example.com]
secretName: admin-example-com-tlsThe default annotations target ingress-nginx. Keep the rewrite-target annotation, which strips the /api prefix, or replicate it for another controller. Raise the body size when you raise --storage-object-size-limit.
Upgrade
helm repo update
helm upgrade spica spica/spica --namespace spica -f values.yaml --version <new version>The migration job runs first, then pods are replaced. Back up the database before upgrading, and read the release notes.
Uninstall
helm uninstall spica --namespace spicaVolume claims created by the StatefulSets (database data, and API data with ReadWriteOnce) are kept. Delete them yourself when you no longer need the data.
See the Helm values reference for every value.