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

Terminal
helm repo add spica https://spica-charts.storage.googleapis.com
helm repo update
helm search repo spica

Create a values file:

values.yaml
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-tls
Terminal
helm install spica spica/spica --namespace spica --create-namespace -f values.yaml --version 0.22.1

When the release is ready, the chart prints where the panel is and the credentials of the default identity:

Text
Web Controller is open at https://admin.example.com/

Credentials are:
  # Username: spica
  # Password: <defaultPassword>

How it fits together

ResourcePurpose
StatefulSet or Deployment <release>-applicationThe API (port 4300, gRPC 50051) and the panel, as two containers of one pod.
Service <release>-applicationExposes the panel and the API inside the cluster.
StatefulSet <release>-databaseMongoDB nodes, or a single PostgreSQL node.
Job <release>-replication-controllerInitializes the MongoDB replica set.
Ingress <release>-applicationRoutes application paths to the panel and api paths to the API.
SecretsThe master key or individual secrets, and database credentials.
Job <release>-migrateRuns 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:

Text
Error: execution error at (spica/templates/applicationsecrets.yaml:35:36): masterKey is absent: .Values.application.secret is required

Choosing the database

YAML
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:

YAML
application:
  args:
    - --bucket-cache=true
    - --function-timeout=120
    - --access-logs=true
  responseHeaders:
    X-Frame-Options: DENY
    Strict-Transport-Security: max-age=31536000

The 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:

ValueWorkload/dataUse when
ReadWriteOnce (default)StatefulSetA volume per podOne replica.
ReadWriteManyDeploymentOne shared volumeSeveral replicas with an RWX storage class (NFS, EFS, Filestore).
NoneDeploymentemptyDir, lost on restartSeveral replicas with S3 or GCS for files and function sources.

A horizontally scaled setup with object storage:

YAML
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-functions

With 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

YAML
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-tls

The 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

Terminal
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

Terminal
helm uninstall spica --namespace spica

Volume 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.