Files
Mikael BergandPaperclip 5ec56f20d5 feat: k8s manifests, Plausible self-host, Dockerfile, CI, and deploy runbook for using.cash
- k8s/using-cash/: namespace, deployment (2 replicas, rolling), service, ingress
  - apex (using.cash) with Let's Encrypt TLS via cert-manager HTTP-01
  - www.using.cash permanent-redirect → using.cash
  - app.using.cash placeholder ingress (DNS slot reserved for product app)
- k8s/analytics/: Plausible CE + Postgres 16 + ClickHouse 24.3 with PVCs
  - stats.using.cash ingress with TLS
  - init containers wait for Postgres and ClickHouse before Plausible starts
  - Secrets created out-of-band; placeholder files document the kubectl commands
- Dockerfile: multi-stage Next.js static export → nginx:alpine (port 8080, non-root)
- nginx.conf: trailing-slash static export support, immutable asset caching, security headers
- .gitea/workflows/deploy.yml: CI build→push→rollout on push to main
- docs/deploy.md: first-apply checklist, DNS cutover procedure, rollback commands

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-05-20 13:56:07 +00:00

144 lines
3.6 KiB
YAML

---
apiVersion: v1
kind: ConfigMap
metadata:
name: plausible-config
namespace: analytics
data:
BASE_URL: "https://stats.using.cash"
DATABASE_URL: "postgres://plausible:$(POSTGRES_PASSWORD)@postgres.analytics.svc.cluster.local:5432/plausible_db"
CLICKHOUSE_DATABASE_URL: "http://clickhouse.analytics.svc.cluster.local:8123/plausible_events_db"
# No cookies, no banner — Plausible default
DISABLE_REGISTRATION: "invite_only"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: plausible
namespace: analytics
labels:
app: plausible
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
selector:
matchLabels:
app: plausible
template:
metadata:
labels:
app: plausible
spec:
initContainers:
# Wait for Postgres to be ready before starting Plausible
- name: wait-for-postgres
image: busybox:1.36
command:
- sh
- -c
- |
until nc -z postgres.analytics.svc.cluster.local 5432; do
echo "waiting for postgres..."; sleep 2;
done
# Wait for ClickHouse to be ready before starting Plausible
- name: wait-for-clickhouse
image: busybox:1.36
command:
- sh
- -c
- |
until nc -z clickhouse.analytics.svc.cluster.local 8123; do
echo "waiting for clickhouse..."; sleep 2;
done
containers:
- name: plausible
image: ghcr.io/plausible/community-edition:v2.1.4
command: ["/bin/sh", "-c", "/entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"]
env:
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: POSTGRES_PASSWORD
- name: DATABASE_URL
value: "postgres://plausible:$(POSTGRES_PASSWORD)@postgres.analytics.svc.cluster.local:5432/plausible_db"
- name: CLICKHOUSE_DATABASE_URL
value: "http://clickhouse.analytics.svc.cluster.local:8123/plausible_events_db"
- name: BASE_URL
value: "https://stats.using.cash"
- name: DISABLE_REGISTRATION
value: "invite_only"
envFrom:
- secretRef:
name: plausible-env
ports:
- containerPort: 8000
name: http
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
livenessProbe:
httpGet:
path: /api/health
port: 8000
initialDelaySeconds: 30
periodSeconds: 15
failureThreshold: 5
readinessProbe:
httpGet:
path: /api/health
port: 8000
initialDelaySeconds: 10
periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: plausible
namespace: analytics
labels:
app: plausible
spec:
type: ClusterIP
selector:
app: plausible
ports:
- name: http
port: 80
targetPort: 8000
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: plausible
namespace: analytics
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: letsencrypt-prod
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
spec:
tls:
- hosts:
- stats.using.cash
secretName: plausible-tls
rules:
- host: stats.using.cash
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: plausible
port:
number: 80