apps(metabase): deploy Metabase (WireGuard-only :8085) with CNPG app DB

- apps/base/metabase: namespace, CNPG Cluster pg (5Gi local-path, siriussec),
  Metabase Deployment v0.65.6.3 (1.5G heap, no PVC), Service, hostname-less
  HTTPRoute on the dedicated metabase Gateway
- infrastructure/networking/internal: new Gateway metabase on port 8085
  (own RouteConfiguration, so it cannot merge with Grafana's bare route)
- host firewall: 8085 in siriussec nft set + rpi ufw guard
This commit is contained in:
Lance Walters 2026-11-22 00:32:31 -05:00
commit 930752152e
13 changed files with 225 additions and 14 deletions

View file

@ -0,0 +1,38 @@
# Metabase's application database (its own metadata only: users, dashboards,
# questions, saved queries — never the data it queries).
#
# Same shape as every other CNPG cluster in this repo: one instance, local-path
# on siriussec, no superuser access. `bootstrap.initdb.secret` names the
# out-of-band Secret `metabase/pg-app` (kubernetes.io/basic-auth, username
# `metabase` — CNPG requires the secret's username to equal `owner`). The
# operator materialises `pg-app` with the same credentials for the Deployment.
#
# No barman ObjectStore yet: the other clusters get WAL archiving to Garage via
# the CNPG-I Barman Cloud plugin; this evaluation instance is deliberately left
# with no archive until Lance keeps it (follow-up card, not a silent gap).
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: pg
namespace: metabase
spec:
instances: 1
imageName: ghcr.io/cloudnative-pg/postgresql:16
storage:
size: 5Gi
storageClass: local-path
affinity:
nodeSelector:
kubernetes.io/hostname: siriussec
bootstrap:
initdb:
database: metabase
owner: metabase
secret:
name: pg-app
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
memory: 1Gi

View file

@ -0,0 +1,83 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: metabase
namespace: metabase
spec:
replicas: 1
selector:
matchLabels:
app: metabase
template:
metadata:
labels:
app: metabase
spec:
# Siriussec is the only gateway node (upstream Envoy has to reach the
# backend pod on the same node), and the CNPG primary is pinned here too.
nodeSelector:
kubernetes.io/hostname: siriussec
tolerations:
- key: dedicated
operator: Exists
effect: PreferNoSchedule
containers:
- name: metabase
# Pinned release tag (2026-11-20, multi-arch). Never latest/nightly:
# Metabase auto-migrates its app DB on start, so an unpinned tag turns
# a pod restart into a schema upgrade.
image: metabase/metabase:v0.65.6.3
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 3000
env:
# One JVM, 1.5 GiB heap, container limit 2 GiB. The laptop is on a
# marginal USB-C supply; a 2 GiB heap here is what starved it in the
# past (see references/laptop-node-power.md).
- name: JAVA_OPTS
value: "-Xmx1536m"
# All state lives in Postgres (no H2 file, no PVC), so the pod is
# disposable and `strategy: Recreate` is unnecessary.
- name: MB_DB_TYPE
value: postgres
- name: MB_DB_HOST
value: pg-rw.metabase.svc.cluster.local
- name: MB_DB_PORT
value: "5432"
- name: MB_DB_DBNAME
value: metabase
- name: MB_DB_USER
valueFrom:
secretKeyRef:
name: pg-app
key: username
- name: MB_DB_PASS
valueFrom:
secretKeyRef:
name: pg-app
key: password
readinessProbe:
httpGet:
path: /api/health
port: 3000
# The JVM takes ~30-60 s to migrate/bootstrap its app DB.
initialDelaySeconds: 20
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
livenessProbe:
httpGet:
path: /api/health
port: 3000
initialDelaySeconds: 120
periodSeconds: 30
timeoutSeconds: 10
failureThreshold: 3
resources:
requests:
cpu: 250m
memory: 1Gi
limits:
cpu: "2"
memory: 2Gi

View file

@ -0,0 +1,25 @@
# Internal only, and deliberately HOSTNAME-LESS: it answers on the bare WireGuard
# address http://10.10.0.2:8085/ for every Host header. Phones cannot edit
# /etc/hosts, so a hostname would make the evaluation unusable on mobile.
#
# parentRefs is the dedicated `metabase` Gateway (infrastructure/networking/
# internal/gateway-metabase.yaml), NOT the shared `internal` one: Cilium merges
# every hostname-less route of a Gateway into one weighted route, so sharing a
# Gateway with Grafana would serve both services on both ports at random.
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: metabase
namespace: metabase
spec:
parentRefs:
- name: metabase
namespace: internal
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: metabase
port: 3000

View file

@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- namespace.yaml
# Secret metabase/pg-app (kubernetes.io/basic-auth) is created out of band
# before this Cluster applies — CNPG's initdb reads it.
- cluster.yaml
- deployment.yaml
- service.yaml
- httproute.yaml

View file

@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: metabase
labels:
app.kubernetes.io/part-of: metabase

View file

@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: metabase
namespace: metabase
spec:
type: ClusterIP
selector:
app: metabase
ports:
- name: http
port: 3000
targetPort: 3000
protocol: TCP

View file

@ -6,3 +6,4 @@ resources:
- ../base/piedmont
- ../base/sirius-growth
- ../base/osint
- ../base/metabase