fluffychat

by lola.2lannoy

Helm chartv0.1.17App 2.11.3AGPL-3.0-or-laterVerified publisher

FluffyChat, a Matrix web client, as a hardened Deployment serving static files

About this chart

fluffychat

FluffyChat, a Matrix web client, as a hardened Deployment serving static files

Runs FluffyChat (a Matrix web client) as a Deployment of static files served by static-web-server. The image is built from spnngl/images: scratch, non-root, no shell. The upstream image is amd64-only and unsigned.

The app is stateless and needs no backend: the browser talks to the Matrix homeserver directly. The chart ships no homeserver.

Install

helm install fluffychat oci://ghcr.io/spnngl/charts/fluffychat --version <version> \
  -n fluffychat --create-namespace --set config.defaultHomeserver=matrix.example.com

config.defaultHomeserver is required: the homeserver pre-filled on the login page.

Settings

Two files, both rendered into one ConfigMap (a change rolls the pods, checksum/config):

  • config is config.json, which the browser fetches next to the page. Keys are the names of the AppSettings enum of the app (lib/config/setting_keys.dart, not the stale sample file). They set defaults only: a setting a user changed in the browser wins, and a value of the wrong type is ignored silently. The schema types the known keys and lets other keys through, for settings added upstream later. The file is public: no secrets. presetHomeserver locks the homeserver on the login page.
  • server is sws.toml, the static-web-server configuration file (options): server.general is the [general] table, server.advanced the [advanced] one (headers, redirects, rewrites, virtual-hosts, typed by the schema; memory-cache needs a build the image does not have). Header values are strings: quote yes, true and numbers, or the server rejects the file and the pod crash-loops (a failed upgrade keeps the old pods serving). The file beats the SERVER_* variables of the image and the command line. health, host, metrics, port and root belong to the chart and are rejected. Three keys are set by default: compression-level, security-headers and grace-period. compression-level is fastest on purpose: the server compresses the files without a precompressed copy (the 7.5 MB source map) on the fly, and at its own default level one brotli request for that file exceeds the memory limit and kills the container.

extraEnv rejects SERVER_* names (the file wins over them anyway) and extraArgs rejects the flags the chart owns. A flag whose option is also set in sws.toml loses to the file. extraVolumeMounts rejects /sws.toml and /config.toml, the paths the server reads as its configuration; /app is the published site root, so files mounted there are served to everyone.

Access

kubectl -n fluffychat port-forward service/fluffychat 8080:8080

then http://localhost:8080/. ingress (Ingress) and httpRoute (Gateway API HTTPRoute) expose it publicly; both need explicit hosts (and parentRefs for the route).

  • Host root only. Sub-paths break asset loading: give the app its own host.
  • HTTPS is mandatory. The app encrypts in the browser with WebCrypto, which browsers only offer on HTTPS (and localhost). The image serves plain HTTP: terminate TLS in front.
  • CORS on the homeserver. The browser calls the homeserver from the app's origin: the homeserver must allow it.
  • Security headers. server.general.security-headers sends X-Frame-Options: DENY and frame-ancestors 'self', which blocks embedding the client in another origin, plus HSTS with preload (a browser that saw it keeps HTTPS-only for two years, subdomains included). Turn it off when another layer sets them or to embed.
  • Caching. The app files keep their names across releases, and the image sends no Cache-Control: a browser could then reuse a stale index.html, service worker or config.json after an upgrade. The chart sends Cache-Control: no-cache on every file by default (server.advanced.headers): the browser revalidates and gets a 304 when unchanged. To cache the heavy files, replace the list with no-cache on /** and a longer max-age on /canvaskit/** and /assets/** (later entries win).

Metrics

metrics.enabled serves Prometheus metrics (GET /metrics) on the app port, without authentication. Any Ingress or HTTPRoute that forwards / publishes them, and a NetworkPolicy cannot close that: the port is shared. Close it in the proxy in front (a rule that denies /metrics), or leave metrics.enabled off when the app is public. metrics.serviceMonitor or metrics.podMonitor (not both) create the scrape resource; metrics.prometheusRule adds two alerts:

  • FluffyChatDown: the target is down or absent for downFor.
  • FluffyChatServerErrors: the share of 5xx responses over serverErrorsWindow exceeds serverErrorsRatio, at more than serverErrorsMinRate requests per second (one 5xx among a handful of requests stays silent).

The alerts select the job label set by the monitor (the Service name for a ServiceMonitor, <namespace>/<name> for a PodMonitor): a relabeling that changes job or namespace silences them. They need the Prometheus Operator CRDs.

Image

The default image is appVersion, pinned by the digest recorded in the artifacthub.io/images annotation of Chart.yaml (Renovate updates tag and digest together). Setting image.tag drops that digest; add image.digest to pin the tag again (a digest without a tag is an error).

The image is signed with cosign (keyless, GitHub Actions OIDC). Verify a digest with:

cosign verify \
  --certificate-identity-regexp 'https://github.com/spnngl/images/.*' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  ghcr.io/spnngl/images/fluffychat@sha256:<digest>

Security

Defaults satisfy the restricted Pod Security Standard: non-root uid/gid 65532, read-only root filesystem, all capabilities dropped, no privilege escalation, RuntimeDefault seccomp, no ServiceAccount token, no Service environment variables. The app writes nothing to disk.

User namespaces

hostUsers: false (default) runs the pod in a user namespace: uid 65532 in the pod maps to an unprivileged host uid, which limits what a container escape gains. Nodes need a container runtime with user namespace support (containerd 2.0+ or CRI-O), runc 1.2+ or crun, and a Linux kernel 6.3+. On other nodes the pod sandbox cannot be created: set hostUsers: true.

Network

The NetworkPolicy (networkPolicy.enabled, on by default) allows the HTTP port (8080) and no egress: the pod serves files and calls nothing. Restrict the sources with networkPolicy.http.from (your ingress controller or Gateway); empty means any source. With metrics.enabled and a non-empty http.from, name your Prometheus in networkPolicy.metrics.from: the port is shared, so the rule opens the whole app to those peers, not /metrics alone.

Availability

Three replicas, spread over nodes and zones, maxUnavailable: 0 during a rolling update, minReadySeconds after readiness. On SIGTERM the server keeps serving for server.general.grace-period seconds, which covers the delay before the endpoint removal reaches the proxies in front; terminationGracePeriodSeconds must exceed it (the chart refuses the install otherwise). podDisruptionBudget is opt-in.

Autoscaling and resources

There is no HPA. verticalPodAutoscaler supports Off, Initial, Recreate and InPlaceOrRecreate (in-place resize needs Kubernetes 1.33+). A recommender started with another --recommender-name than default ignores the VPA unless verticalPodAutoscaler.recommender names it. The default requests (10m CPU, 16Mi memory) are scheduling floors, not a sizing: measure then tune.

Compatibility

The values schema is strict: unknown keys fail the install (config is the exception: unknown keys pass). A breaking change to values bumps the chart MAJOR version; deprecations are announced one MINOR version ahead. Requires Kubernetes 1.33 or later.

Maintainers

NameEmailUrl
spnnglhttps://github.com/spnngl

Source Code

Requirements

Kubernetes: >=1.33.0-0

Values

KeyTypeDefaultDescription
affinityobject{}Affinity, merged over the chart default: a preferred pod anti-affinity that spreads the replicas over nodes (set podAntiAffinity to replace it).
configobject{"defaultHomeserver":"example.com"}Contents of config.json, which the browser fetches next to the page. Keys are the names of the AppSettings enum in lib/config/setting_keys.dart (not the sample file, which is stale). They set defaults only: a setting a user changed in the browser wins, and a value of the wrong type is ignored silently, so the schema types the known keys and lets others through (additionalProperties). defaultHomeserver is required: the homeserver pre-filled on the login page (presetHomeserver also locks it). The file is public: no secrets. The state keys the app writes itself (autoSendErrorReports, knownErrorHashes, lastUpdateCheckDate, noEncryptionWarningShown, unifiedPushEndpoint, unifiedPushRegistered) are rejected.
dnsConfigobject{"options":[{"name":"ndots","value":"2"}]}DNS config.
dnsConfig.optionslist[{"name":"ndots","value":"2"}]DNS options.
extraArgslist[]Extra static-web-server command-line flags. Flags the chart owns (-a, -p, -d, -q, -w, --host, --port, --root, --health, --metrics, --config-file) are rejected. A flag whose option is also set in sws.toml loses to the file.
extraEnvlist[]Extra environment variables (EnvVar list). SERVER_* names are rejected: they configure the server, which reads /sws.toml first (use server).
extraVolumeMountslist[]Extra volume mounts. /sws.toml and /config.toml are rejected: the server reads them as its configuration file, which belongs to the chart. /app is the published site root: mounting there serves the files to everyone.
extraVolumeslist[]Extra volumes.
fullnameOverridestring""Override the full resource name (default <release>-<chart>).
hostUsersboolfalseRun the pod in a user namespace (false: uid 65532 maps to an unprivileged host uid). Needs node support (containerd 2.0+ or CRI-O, runc 1.2+, kernel 6.3+); pods fail to start otherwise. true uses host users.
httpRoute.annotationsobject{}HTTPRoute annotations.
httpRoute.enabledboolfalseCreate a Gateway API HTTPRoute (path prefix /). FluffyChat needs a host root: sub-paths break asset loading. /metrics is served on the same port: see the README.
httpRoute.hostnameslist[]Host names (empty: any host of the Gateway listener).
httpRoute.labelsobject{}Extra HTTPRoute labels.
httpRoute.parentRefslist[]Gateways (parentRefs). Required when enabled.
image.digeststring""Image digest, only valid together with image.tag.
image.pullPolicystring"IfNotPresent"Image pull policy.
image.repositorystring"ghcr.io/spnngl/images/fluffychat"Image repository.
image.tagstring""Image tag. Empty: the tag and digest recorded for image.repository in the artifacthub.io/images annotation of Chart.yaml. When set, the chart digest is not applied; add image.digest to pin it.
imagePullSecretslist[]Image pull secrets (list of {name: <secret>}).
ingress.annotationsobject{}Ingress annotations.
ingress.classNamestring""Ingress class name (empty: cluster default).
ingress.enabledboolfalseCreate an Ingress (path /). FluffyChat needs a host root: sub-paths break asset loading. /metrics is served on the same port: see the README.
ingress.hostslist[]Host names. Required when enabled.
ingress.labelsobject{}Extra Ingress labels (for example the label an external-dns --label-filter selects).
ingress.tlslist[]Ingress TLS blocks (secretName, hosts).
livenessProbeobject{"failureThreshold":3,"periodSeconds":10,"timeoutSeconds":2}Liveness probe (GET /health).
metrics.enabledboolfalseServe Prometheus metrics (GET /metrics) on the app port, without authentication: an Ingress or HTTPRoute that forwards / exposes them. See the README.
metrics.podMonitor.enabledboolfalseCreate a Prometheus Operator PodMonitor (needs metrics.enabled). Exclusive with serviceMonitor.
metrics.podMonitor.intervalstring""Scrape interval (empty: Prometheus default).
metrics.podMonitor.labelsobject{}Extra labels.
metrics.podMonitor.metricRelabelingslist[]Metric relabelings.
metrics.podMonitor.relabelingslist[]Relabelings.
metrics.podMonitor.scrapeTimeoutstring""Scrape timeout (empty: Prometheus default).
metrics.prometheusRule.disabledlist[]Alerts to leave out, at most one (to drop both, disable prometheusRule).
metrics.prometheusRule.downForstring"5m"How long the target may be down or absent before FluffyChatDown fires.
metrics.prometheusRule.enabledboolfalseCreate a Prometheus Operator PrometheusRule (alerts FluffyChatDown, FluffyChatServerErrors). Needs serviceMonitor or podMonitor: the rules select the job label it sets.
metrics.prometheusRule.labelsobject{}Extra labels (for example `release: k

Deploy fluffychat with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has fluffychat on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartfluffychat is pinned at v0.1.17 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply