Compare commits

..

2 commits

Author SHA1 Message Date
un-oeil
f9c3ffa942 premier tests 2026-10-11 21:03:33 +02:00
un-oeil
8c418c3a3a Add Sealed Secrets, Longhorn, Traefik config and scripts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 21:00:22 +02:00
84 changed files with 2034 additions and 22 deletions

184
README.md
View file

@ -10,34 +10,149 @@ bootstrap/root.yaml the only thing applied by hand: the "root" Application ->
cluster/ cluster-level Argo objects (app-of-apps)
argocd.yaml Argo CD manages its own install from argocd-install/
apps.yaml ApplicationSet: one Application per folder in apps/
sealed-secrets.yaml Sealed Secrets controller (kube-system)
longhorn.yaml Longhorn storage (longhorn-system)
traefik-config.yaml tweaks to k3s's Traefik, from infra/traefik/
argocd-install/ Argo CD install (upstream install.yaml pinned + small patches)
infra/ plain manifests used by cluster/ Applications
apps/<name>/ one app per folder, deployed to namespace <name>
scripts/ prep-worker.sh (Longhorn prerequisites), seal-secrets.sh
```
Argo reads the repo at `http://10.0.0.14:3000/un-oeil/argocd.git` (Forgejo's
internal address): pods can't reach `forgejo.un-oeil.fr` because the host has no
hairpin NAT. The repo is public, so no credentials are needed.
internal address). The repo is public, so no credentials are needed.
## Bootstrap (once)
## Apps
Over WireGuard, with `KUBECONFIG=~/.kube/k3s-homelab.yaml`. Push this repo first:
Argo pulls from Forgejo, not from your laptop.
| App | URL | Data | Database |
|---|---|---|---|
| homepage | home.un-oeil.fr | config in git | none |
| ntfy | ntfy.un-oeil.fr | 2 Gi | SQLite |
| wikijs | wiki.un-oeil.fr | none | Postgres |
| paperless | paperless.un-oeil.fr | 2 + 50 + 5 Gi | Postgres + Valkey |
| linkwarden | links.un-oeil.fr | 20 Gi | Postgres |
| firefly | firefly.un-oeil.fr | 2 Gi | Postgres |
| hedgedoc | md.un-oeil.fr | 5 Gi | Postgres |
| freshrss | rss.un-oeil.fr | 2 Gi | SQLite |
| vikunja | tasks.un-oeil.fr | 5 Gi | SQLite |
| n8n | n8n.un-oeil.fr | 2 Gi | SQLite |
| searxng | search.un-oeil.fr | none | none |
| privatebin | paste.un-oeil.fr | 1 Gi | files |
| stirling-pdf | pdf.un-oeil.fr | none | none |
| it-tools | tools.un-oeil.fr | none | none |
| postgres | (internal) `postgres.postgres.svc` | 10 Gi | shared by the 5 above |
| whoami | (example, no DNS) | none | none |
Every volume is Longhorn, 2 replicas, on the workers' `sdb`. Total requests are
about 3 GiB RAM and 110 GiB of volumes (×2 replicas = 220 of 600 GiB).
## First rollout (in this order)
Over WireGuard, with `KUBECONFIG=~/.kube/k3s-homelab.yaml`.
**1. Prepare the workers for Longhorn.** On each of `10.0.0.141`, `.142`, `.143`:
```bash
kubectl apply --server-side -k argocd-install/
kubectl -n argocd rollout status deploy/argocd-server
kubectl apply -f bootstrap/root.yaml
ssh un-oeil@10.0.0.141 'sudo bash -s' < scripts/prep-worker.sh
```
It formats `/dev/sdb`, which is the worker's own empty 200 GB disk (the zvol
`hdd-mirror/vm-disks/vm-14x-disk-0` on the host). It is **not**
`/hdd-mirror/vzdump-backups` or `hdd-mirror/restic-repo`. The script stops if
`sdb` isn't 200 GB or already holds anything. It also installs `open-iscsi` and
`nfs-common`.
**2. Push the cluster layer only:**
```bash
git add cluster/ infra/ scripts/ README.md
git commit -m "Add Sealed Secrets, Longhorn, Traefik config"
git push
```
Wait until both are healthy:
```bash
kubectl -n kube-system rollout status deploy/sealed-secrets-controller
kubectl -n longhorn-system get pods # all Running
kubectl get nodes.longhorn.io -n longhorn-system # 3 workers, Ready
```
Admin password (user `admin`), then change it in the UI and delete the secret:
**3. Back up the Sealed Secrets key.** Without it, nobody can decrypt the
secrets in this repo after a cluster rebuild. Keep it out of git, e.g. in
Vaultwarden:
```bash
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 -d; echo
kubectl -n kube-system get secret -l sealedsecrets.bitnami.com/sealed-secrets-key -o yaml > sealed-secrets-key.yaml
```
UI: either `kubectl -n argocd port-forward svc/argocd-server 8080:80` →
http://localhost:8080, or add `10.0.0.141 argocd.un-oeil.fr` to `/etc/hosts` →
http://argocd.un-oeil.fr. Argo CD is admin-only: **don't add it to Caddy**.
**4. Generate and seal the app secrets**, then push the apps:
```bash
scripts/seal-secrets.sh
git add apps/
git commit -m "Add apps"
git push
```
Postgres needs to start before the five apps that use it. Those apps restart
a few times until it's ready, which is normal.
**5. Caddy (LXC 100).** One block for every app. Caddy keeps the `Host` header,
and Traefik routes on it:
```
home.un-oeil.fr, ntfy.un-oeil.fr, wiki.un-oeil.fr, paperless.un-oeil.fr,
links.un-oeil.fr, firefly.un-oeil.fr, md.un-oeil.fr, rss.un-oeil.fr,
tasks.un-oeil.fr, n8n.un-oeil.fr, search.un-oeil.fr, paste.un-oeil.fr,
pdf.un-oeil.fr, tools.un-oeil.fr {
reverse_proxy 10.0.0.141:80 10.0.0.142:80 10.0.0.143:80 {
lb_policy round_robin
fail_duration 30s
# ntfy and HedgeDoc stream
flush_interval -1
}
}
```
Then `env $(cat /etc/caddy/infomaniak.env) caddy validate --config /etc/caddy/Caddyfile && systemctl reload caddy`.
Expect 14 `certificate obtained` lines in the journal.
**6. DNS.** Add the 14 A records → `10.0.0.10` at Infomaniak (zone file in
`../infomaniak-zone-un-oeil.fr.txt`).
## After the first deploy
- **Paperless:** user `admin`. Read the password with
`kubectl -n paperless get secret paperless-secrets -o jsonpath='{.data.PAPERLESS_ADMIN_PASSWORD}' | base64 -d`, then change it.
- **Wiki.js, FreshRSS, n8n, Firefly, Linkwarden, HedgeDoc, Vikunja:** the
first visit creates the admin or owner account. Do it right after the deploy.
- **Vikunja:** once your account exists, set `VIKUNJA_SERVICE_ENABLEREGISTRATION`
to `"false"` in `apps/vikunja/deployment.yaml`.
- **HedgeDoc:** same, with `CMD_ALLOW_EMAIL_REGISTER: "false"`.
- **ntfy:** nobody can use it until you create users:
```bash
kubectl -n ntfy exec deploy/ntfy -- ntfy user add --role=admin un-oeil
kubectl -n ntfy exec deploy/ntfy -- ntfy token add un-oeil # for Uptime Kuma / scripts
```
- **Uptime Kuma:** add the 14 URLs (`uptime-kuma-monitors.md` §3), plus a
Push monitor for the Postgres backup below.
## Postgres backups
`apps/postgres/backup-cronjob.yaml` streams `pg_dumpall` into restic on LXC 105
every night at 02:45, keeps 7 daily / 4 weekly / 3 monthly, then pings Uptime
Kuma. It's suspended until it has credentials:
1. On LXC 105, add a rest-server user `k3s-postgres`, named after its repo like
the existing ones (`--private-repos` limits each user to its own path):
`htpasswd -B /etc/restic-htpasswd k3s-postgres && systemctl restart rest-server`
2. Create a Push monitor "Backup – Postgres (k3s)" in Kuma, interval 90000 s.
3. Seal the credentials. The script adds them to the kustomization:
```bash
RESTIC_REPOSITORY='rest:http://k3s-postgres:<pw>@10.0.0.15:8000/k3s-postgres' \
RESTIC_PASSWORD='<new repo password, keep it in Vaultwarden>' \
KUMA_PUSH_URL='https://status.un-oeil.fr/api/push/<token>?status=up&msg=OK' \
scripts/seal-secrets.sh
```
4. Set `suspend: false` in the CronJob, push, then test it once:
`kubectl -n postgres create job --from=cronjob/postgres-backup test-backup`.
**Not covered:** the files on Longhorn volumes (Paperless documents, Linkwarden
archives, uploads). The workers' `sdb` disks are excluded from vzdump
(`backup=0`), and Longhorn has no backup target yet. Longhorn's backup target
can be an NFS export or S3 bucket, e.g. on the restic LXC. Until then, those
files survive a node failure (2 replicas) but not the loss of the pool.
## Launching an app
@ -45,15 +160,40 @@ http://argocd.un-oeil.fr. Argo CD is admin-only: **don't add it to Caddy**.
- plain manifests, or
- a `kustomization.yaml` (Helm charts work too via `helmCharts:`), or
- a `Chart.yaml` (umbrella chart with the real chart as a dependency + `values.yaml`).
2. Commit and push. Argo picks it up within ~3 min (or hit *Refresh* in the UI)
and creates namespace `<name>`.
3. To make it public: add an Ingress with host `<name>.un-oeil.fr`, then a Caddy
vhost (LXC 100) pointing at Traefik on `10.0.0.141-143:80`.
2. Volumes: `storageClassName: longhorn`, and `strategy: Recreate` on the
Deployment (a Longhorn volume attaches to one node at a time).
3. Secrets: add a `seal` line to `scripts/seal-secrets.sh`, or run `kubeseal`
by hand. Never commit a plain Secret.
4. A Postgres database: create it by hand, because the init script only runs on
the first start:
`kubectl -n postgres exec -it postgres-0 -- psql -U postgres -c "CREATE ROLE x LOGIN PASSWORD '...'" -c "CREATE DATABASE x OWNER x"`
5. Commit and push. Argo picks it up within ~3 min and creates namespace `<name>`.
6. Ingress host `<name>.un-oeil.fr`, add the name to the Caddy block above, and
an A record → `10.0.0.10`.
Removing a folder deletes the app **and its resources, PVCs included**.
Longhorn, Sealed Secrets and Argo CD itself have `prune: false`, so a bad
commit can't delete them.
## Not there yet
## Bootstrap (once, already done 2026-10-09)
- Storage: only k3s `local-path` (data stuck on one node). Longhorn is the next app.
- Secrets: nothing yet. Don't commit plain Secrets; add Sealed Secrets or SOPS first.
- Forgejo webhook → Argo for instant syncs instead of 3 min polling.
```bash
kubectl apply --server-side -k argocd-install/
kubectl -n argocd rollout status deploy/argocd-server
kubectl apply -f bootstrap/root.yaml
```
Argo CD UI: `kubectl -n argocd port-forward svc/argocd-server 8080:80`, or
`10.0.0.141 argocd.un-oeil.fr` in `/etc/hosts`. It's admin-only: **don't add
it to Caddy**. Same for the Longhorn UI:
`kubectl -n longhorn-system port-forward svc/longhorn-frontend 8081:80`.
## Before relying on it
- Image versions were current on 2026-10-11. Several are new major versions
(Paperless 3, Vikunja 2, n8n 2, Homepage 2, Stirling-PDF 3), so check their
release notes for renamed settings if one misbehaves.
- Traefik trusts `X-Forwarded-For` from `10.0.0.0/24` and the pod network, so
apps see real client IPs through Caddy. Someone on WireGuard who hits Traefik
directly could fake that header. That's acceptable for a private network.
- Not there yet: Forgejo webhook → Argo for instant syncs, Longhorn backup
target, kube-vip on `.139`.

28
apps/firefly/cronjob.yaml Normal file
View file

@ -0,0 +1,28 @@
# Firefly's daily job (recurring transactions, bill reminders, auto-budgets).
apiVersion: batch/v1
kind: CronJob
metadata:
name: firefly-cron
spec:
schedule: "0 3 * * *"
timeZone: Europe/Paris
concurrencyPolicy: Forbid
jobTemplate:
spec:
backoffLimit: 2
template:
spec:
restartPolicy: Never
containers:
- name: cron
image: curlimages/curl:8.22.0
env:
- name: STATIC_CRON_TOKEN
valueFrom:
secretKeyRef:
name: firefly-secrets
key: STATIC_CRON_TOKEN
command:
- /bin/sh
- -c
- curl -fsS -m 300 "http://firefly/api/v1/cron/$STATIC_CRON_TOKEN"

View file

@ -0,0 +1,61 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: firefly
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: firefly
template:
metadata:
labels:
app: firefly
spec:
securityContext:
# The image runs as www-data (33).
fsGroup: 33
containers:
- name: firefly
image: fireflyiii/core:version-6.7.8
ports:
- name: http
containerPort: 8080
# APP_KEY, DB_PASSWORD, STATIC_CRON_TOKEN.
envFrom:
- secretRef:
name: firefly-secrets
env:
- name: APP_URL
value: https://firefly.un-oeil.fr
- name: TRUSTED_PROXIES
value: "**"
- name: TZ
value: Europe/Paris
- name: DEFAULT_LANGUAGE
value: fr_FR
- name: DB_CONNECTION
value: pgsql
- name: DB_HOST
value: postgres.postgres.svc
- name: DB_PORT
value: "5432"
- name: DB_DATABASE
value: firefly
- name: DB_USERNAME
value: firefly
volumeMounts:
- name: upload
mountPath: /var/www/html/storage/upload
resources:
requests:
cpu: 50m
memory: 128Mi
limits:
memory: 512Mi
volumes:
- name: upload
persistentVolumeClaim:
claimName: firefly-upload

18
apps/firefly/ingress.yaml Normal file
View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: firefly
spec:
ingressClassName: traefik
rules:
- host: firefly.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: firefly
port:
name: http

View file

@ -0,0 +1,10 @@
# Personal finance, data in the shared Postgres. https://firefly.un-oeil.fr
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- sealed-secret.yaml
- pvc.yaml
- deployment.yaml
- service.yaml
- ingress.yaml
- cronjob.yaml

10
apps/firefly/pvc.yaml Normal file
View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: firefly-upload
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: longhorn
resources:
requests:
storage: 2Gi

11
apps/firefly/service.yaml Normal file
View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: firefly
spec:
selector:
app: firefly
ports:
- name: http
port: 80
targetPort: http

View file

@ -0,0 +1,47 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: freshrss
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: freshrss
template:
metadata:
labels:
app: freshrss
spec:
containers:
- name: freshrss
image: freshrss/freshrss:1.30.1
ports:
- name: http
containerPort: 80
env:
- name: TZ
value: Europe/Paris
# Refresh feeds every 20 min (built-in cron).
- name: CRON_MIN
value: "*/20"
- name: TRUSTED_PROXY
value: 10.42.0.0/16
volumeMounts:
- name: data
mountPath: /var/www/FreshRSS/data
subPath: data
- name: data
mountPath: /var/www/FreshRSS/extensions
subPath: extensions
resources:
requests:
cpu: 20m
memory: 64Mi
limits:
memory: 256Mi
volumes:
- name: data
persistentVolumeClaim:
claimName: freshrss-data

View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: freshrss
spec:
ingressClassName: traefik
rules:
- host: rss.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: freshrss
port:
name: http

View file

@ -0,0 +1,8 @@
# RSS reader, SQLite. First visit runs the setup wizard. https://rss.un-oeil.fr
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- pvc.yaml
- deployment.yaml
- service.yaml
- ingress.yaml

10
apps/freshrss/pvc.yaml Normal file
View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: freshrss-data
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: longhorn
resources:
requests:
storage: 2Gi

View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: freshrss
spec:
selector:
app: freshrss
ports:
- name: http
port: 80
targetPort: http

View file

@ -0,0 +1,59 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hedgedoc
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: hedgedoc
template:
metadata:
labels:
app: hedgedoc
spec:
securityContext:
fsGroup: 10000
containers:
- name: hedgedoc
image: quay.io/hedgedoc/hedgedoc:1.12.0
ports:
- name: http
containerPort: 3000
# CMD_DB_URL (postgres://hedgedoc:...@postgres.postgres.svc/hedgedoc)
# and CMD_SESSION_SECRET.
envFrom:
- secretRef:
name: hedgedoc-secrets
env:
- name: CMD_DOMAIN
value: md.un-oeil.fr
- name: CMD_PROTOCOL_USESSL
value: "true"
- name: CMD_URL_ADDPORT
value: "false"
# Only people with an account can create notes.
- name: CMD_ALLOW_ANONYMOUS
value: "false"
- name: CMD_ALLOW_EMAIL_REGISTER
value: "true"
volumeMounts:
- name: uploads
mountPath: /hedgedoc/public/uploads
readinessProbe:
httpGet:
path: /_health
port: http
initialDelaySeconds: 15
resources:
requests:
cpu: 50m
memory: 128Mi
limits:
memory: 512Mi
volumes:
- name: uploads
persistentVolumeClaim:
claimName: hedgedoc-uploads

View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hedgedoc
spec:
ingressClassName: traefik
rules:
- host: md.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hedgedoc
port:
name: http

View file

@ -0,0 +1,9 @@
# Collaborative markdown, data in the shared Postgres. https://md.un-oeil.fr
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- sealed-secret.yaml
- pvc.yaml
- deployment.yaml
- service.yaml
- ingress.yaml

10
apps/hedgedoc/pvc.yaml Normal file
View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hedgedoc-uploads
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: longhorn
resources:
requests:
storage: 5Gi

View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: hedgedoc
spec:
selector:
app: hedgedoc
ports:
- name: http
port: 80
targetPort: http

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1,98 @@
# siteMonitor: Homepage checks each URL itself and shows a green/red dot.
# Uptime Kuma (status.un-oeil.fr) remains the source of alerts.
- Infra:
- Proxmox:
href: https://proxmox.un-oeil.fr
siteMonitor: https://proxmox.un-oeil.fr
icon: proxmox.svg
- Uptime Kuma:
href: https://status.un-oeil.fr
siteMonitor: https://status.un-oeil.fr
icon: uptime-kuma.svg
- Pelican:
href: https://pelican.un-oeil.fr
siteMonitor: https://pelican.un-oeil.fr
icon: pelican-panel.svg
- ntfy:
href: https://ntfy.un-oeil.fr
siteMonitor: https://ntfy.un-oeil.fr/v1/health
icon: ntfy.svg
- Services:
- Nextcloud:
href: https://cloud.un-oeil.fr
siteMonitor: https://cloud.un-oeil.fr/status.php
icon: nextcloud.svg
- Vaultwarden:
href: https://vault.un-oeil.fr
siteMonitor: https://vault.un-oeil.fr/alive
icon: vaultwarden.svg
- Forgejo:
href: https://forgejo.un-oeil.fr
siteMonitor: https://forgejo.un-oeil.fr/api/healthz
icon: forgejo.svg
- Jellyfin:
href: https://jellyfin.un-oeil.fr
siteMonitor: https://jellyfin.un-oeil.fr/health
icon: jellyfin.svg
- Overleaf:
href: https://latex.un-oeil.fr
siteMonitor: https://latex.un-oeil.fr
icon: overleaf.svg
- Paperless:
href: https://paperless.un-oeil.fr
siteMonitor: https://paperless.un-oeil.fr
icon: paperless-ngx.svg
- Wiki.js:
href: https://wiki.un-oeil.fr
siteMonitor: https://wiki.un-oeil.fr/healthz
icon: wikijs.svg
- Firefly III:
href: https://firefly.un-oeil.fr
siteMonitor: https://firefly.un-oeil.fr
icon: firefly.svg
- Leaderboard:
href: https://leaderboard.un-oeil.fr
siteMonitor: https://leaderboard.un-oeil.fr
- Outils:
- Etherpad:
href: https://pad.un-oeil.fr
siteMonitor: https://pad.un-oeil.fr
icon: etherpad.svg
- HedgeDoc:
href: https://md.un-oeil.fr
siteMonitor: https://md.un-oeil.fr/_health
icon: hedgedoc.svg
- Vikunja:
href: https://tasks.un-oeil.fr
siteMonitor: https://tasks.un-oeil.fr
icon: vikunja.svg
- FreshRSS:
href: https://rss.un-oeil.fr
siteMonitor: https://rss.un-oeil.fr
icon: freshrss.svg
- Linkwarden:
href: https://links.un-oeil.fr
siteMonitor: https://links.un-oeil.fr
icon: linkwarden.svg
- SearXNG:
href: https://search.un-oeil.fr
siteMonitor: https://search.un-oeil.fr/healthz
icon: searxng.svg
- n8n:
href: https://n8n.un-oeil.fr
siteMonitor: https://n8n.un-oeil.fr/healthz
icon: n8n.svg
- PrivateBin:
href: https://paste.un-oeil.fr
siteMonitor: https://paste.un-oeil.fr
icon: privatebin.svg
- Stirling-PDF:
href: https://pdf.un-oeil.fr
siteMonitor: https://pdf.un-oeil.fr
icon: stirling-pdf.svg
- IT-Tools:
href: https://tools.un-oeil.fr
siteMonitor: https://tools.un-oeil.fr
icon: it-tools.svg

View file

@ -0,0 +1,15 @@
title: un-oeil homelab
language: fr
theme: dark
color: slate
headerStyle: clean
layout:
Infra:
style: row
columns: 4
Services:
style: row
columns: 4
Outils:
style: row
columns: 4

View file

@ -0,0 +1,9 @@
- search:
provider: custom
url: https://search.un-oeil.fr/search?q=
target: _blank
- datetime:
text_size: md
format:
dateStyle: long
timeStyle: short

View file

@ -0,0 +1,53 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: homepage
spec:
replicas: 1
selector:
matchLabels:
app: homepage
template:
metadata:
labels:
app: homepage
spec:
containers:
- name: homepage
image: ghcr.io/gethomepage/homepage:v2.5.0
ports:
- name: http
containerPort: 3000
env:
- name: HOMEPAGE_ALLOWED_HOSTS
value: home.un-oeil.fr
volumeMounts:
# Homepage writes to /app/config (logs, missing default files), so
# the directory is writable and only our files come from the
# ConfigMap.
- name: config-dir
mountPath: /app/config
- name: config
mountPath: /app/config/settings.yaml
subPath: settings.yaml
- name: config
mountPath: /app/config/services.yaml
subPath: services.yaml
- name: config
mountPath: /app/config/widgets.yaml
subPath: widgets.yaml
- name: config
mountPath: /app/config/bookmarks.yaml
subPath: bookmarks.yaml
resources:
requests:
cpu: 20m
memory: 64Mi
limits:
memory: 256Mi
volumes:
- name: config-dir
emptyDir: {}
- name: config
configMap:
name: homepage-config

View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: homepage
spec:
ingressClassName: traefik
rules:
- host: home.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: homepage
port:
name: http

View file

@ -0,0 +1,15 @@
# Start page with links to every service. https://home.un-oeil.fr
# Edit config/*.yaml and push; the pod restarts with the new config.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml
- ingress.yaml
configMapGenerator:
- name: homepage-config
files:
- config/settings.yaml
- config/services.yaml
- config/widgets.yaml
- config/bookmarks.yaml

View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: homepage
spec:
selector:
app: homepage
ports:
- name: http
port: 80
targetPort: http

View file

@ -0,0 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: it-tools
spec:
replicas: 1
selector:
matchLabels:
app: it-tools
template:
metadata:
labels:
app: it-tools
spec:
containers:
- name: it-tools
image: corentinth/it-tools:2024.10.22-7ca5933
ports:
- name: http
containerPort: 80
resources:
requests:
cpu: 10m
memory: 16Mi
limits:
memory: 64Mi

View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: it-tools
spec:
ingressClassName: traefik
rules:
- host: tools.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: it-tools
port:
name: http

View file

@ -0,0 +1,7 @@
# Developer utilities, static site, no data. https://tools.un-oeil.fr
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml
- ingress.yaml

View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: it-tools
spec:
selector:
app: it-tools
ports:
- name: http
port: 80
targetPort: http

View file

@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: linkwarden
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: linkwarden
template:
metadata:
labels:
app: linkwarden
spec:
containers:
- name: linkwarden
image: ghcr.io/linkwarden/linkwarden:v2.16.3
ports:
- name: http
containerPort: 3000
# DATABASE_URL and NEXTAUTH_SECRET.
envFrom:
- secretRef:
name: linkwarden-secrets
env:
- name: NEXTAUTH_URL
value: https://links.un-oeil.fr/api/v1/auth
volumeMounts:
# Page archives (screenshots, PDFs, readable copies).
- name: data
mountPath: /data/data
resources:
requests:
cpu: 100m
memory: 512Mi
# Archiving runs a headless Chromium.
limits:
memory: 2Gi
volumes:
- name: data
persistentVolumeClaim:
claimName: linkwarden-data

View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: linkwarden
spec:
ingressClassName: traefik
rules:
- host: links.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: linkwarden
port:
name: http

View file

@ -0,0 +1,9 @@
# Bookmarks + page archives, data in the shared Postgres. https://links.un-oeil.fr
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- sealed-secret.yaml
- pvc.yaml
- deployment.yaml
- service.yaml
- ingress.yaml

10
apps/linkwarden/pvc.yaml Normal file
View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: linkwarden-data
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: longhorn
resources:
requests:
storage: 20Gi

View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: linkwarden
spec:
selector:
app: linkwarden
ports:
- name: http
port: 80
targetPort: http

58
apps/n8n/deployment.yaml Normal file
View file

@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: n8n
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: n8n
template:
metadata:
labels:
app: n8n
spec:
securityContext:
# The image runs as node (1000).
fsGroup: 1000
containers:
- name: n8n
image: n8nio/n8n:2.43.3
ports:
- name: http
containerPort: 5678
envFrom:
- secretRef:
name: n8n-secrets
env:
- name: N8N_HOST
value: n8n.un-oeil.fr
- name: N8N_PROTOCOL
value: https
- name: WEBHOOK_URL
value: https://n8n.un-oeil.fr/
- name: N8N_PROXY_HOPS
value: "1"
- name: GENERIC_TIMEZONE
value: Europe/Paris
- name: TZ
value: Europe/Paris
volumeMounts:
- name: data
mountPath: /home/node/.n8n
readinessProbe:
httpGet:
path: /healthz
port: http
resources:
requests:
cpu: 50m
memory: 256Mi
limits:
memory: 1Gi
volumes:
- name: data
persistentVolumeClaim:
claimName: n8n-data

18
apps/n8n/ingress.yaml Normal file
View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: n8n
spec:
ingressClassName: traefik
rules:
- host: n8n.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: n8n
port:
name: http

View file

@ -0,0 +1,9 @@
# Workflow automation, SQLite. First visit creates the owner account. https://n8n.un-oeil.fr
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- sealed-secret.yaml
- pvc.yaml
- deployment.yaml
- service.yaml
- ingress.yaml

10
apps/n8n/pvc.yaml Normal file
View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: n8n-data
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: longhorn
resources:
requests:
storage: 2Gi

11
apps/n8n/service.yaml Normal file
View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: n8n
spec:
selector:
app: n8n
ports:
- name: http
port: 80
targetPort: http

17
apps/ntfy/configmap.yaml Normal file
View file

@ -0,0 +1,17 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: ntfy-config
data:
server.yml: |
base-url: https://ntfy.un-oeil.fr
behind-proxy: true
cache-file: /var/lib/ntfy/cache.db
attachment-cache-dir: /var/lib/ntfy/attachments
# Nobody can read or publish without an account. Create users with
# `ntfy user add` (README).
auth-file: /var/lib/ntfy/user.db
auth-default-access: deny-all
# iOS only gets instant notifications through ntfy.sh's relay (it carries
# a poll request, not the message).
upstream-base-url: https://ntfy.sh

45
apps/ntfy/deployment.yaml Normal file
View file

@ -0,0 +1,45 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ntfy
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: ntfy
template:
metadata:
labels:
app: ntfy
spec:
containers:
- name: ntfy
image: binwiederhier/ntfy:v2.29.0
args: ["serve"]
ports:
- name: http
containerPort: 80
volumeMounts:
- name: config
mountPath: /etc/ntfy
- name: data
mountPath: /var/lib/ntfy
readinessProbe:
httpGet:
path: /v1/health
port: http
resources:
requests:
cpu: 10m
memory: 32Mi
limits:
memory: 128Mi
volumes:
- name: config
configMap:
name: ntfy-config
- name: data
persistentVolumeClaim:
claimName: ntfy-data

18
apps/ntfy/ingress.yaml Normal file
View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ntfy
spec:
ingressClassName: traefik
rules:
- host: ntfy.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: ntfy
port:
name: http

View file

@ -0,0 +1,9 @@
# Push notifications (Uptime Kuma, CrowdSec, n8n...). https://ntfy.un-oeil.fr
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- configmap.yaml
- pvc.yaml
- deployment.yaml
- service.yaml
- ingress.yaml

10
apps/ntfy/pvc.yaml Normal file
View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ntfy-data
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: longhorn
resources:
requests:
storage: 2Gi

11
apps/ntfy/service.yaml Normal file
View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: ntfy
spec:
selector:
app: ntfy
ports:
- name: http
port: 80
targetPort: http

View file

@ -0,0 +1,76 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: paperless
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: paperless
template:
metadata:
labels:
app: paperless
spec:
containers:
- name: paperless
image: ghcr.io/paperless-ngx/paperless-ngx:3.3.0
ports:
- name: http
containerPort: 8000
# PAPERLESS_DBPASS, PAPERLESS_SECRET_KEY, PAPERLESS_ADMIN_PASSWORD.
envFrom:
- secretRef:
name: paperless-secrets
env:
- name: PAPERLESS_URL
value: https://paperless.un-oeil.fr
- name: PAPERLESS_REDIS
value: redis://valkey:6379
- name: PAPERLESS_DBHOST
value: postgres.postgres.svc
- name: PAPERLESS_DBUSER
value: paperless
- name: PAPERLESS_DBNAME
value: paperless
# Created on first start only. Change the password in the UI.
- name: PAPERLESS_ADMIN_USER
value: admin
- name: PAPERLESS_OCR_LANGUAGE
value: fra+eng
- name: PAPERLESS_TIME_ZONE
value: Europe/Paris
# Longhorn volumes don't send inotify events reliably.
- name: PAPERLESS_CONSUMER_POLLING
value: "30"
volumeMounts:
- name: data
mountPath: /usr/src/paperless/data
- name: media
mountPath: /usr/src/paperless/media
- name: consume
mountPath: /usr/src/paperless/consume
readinessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 60
resources:
requests:
cpu: 100m
memory: 512Mi
# OCR is the memory-hungry part.
limits:
memory: 2Gi
volumes:
- name: data
persistentVolumeClaim:
claimName: paperless-data
- name: media
persistentVolumeClaim:
claimName: paperless-media
- name: consume
persistentVolumeClaim:
claimName: paperless-consume

View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: paperless
spec:
ingressClassName: traefik
rules:
- host: paperless.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: paperless
port:
name: http

View file

@ -0,0 +1,10 @@
# Document OCR + archive, metadata in the shared Postgres. https://paperless.un-oeil.fr
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- sealed-secret.yaml
- pvc.yaml
- valkey.yaml
- deployment.yaml
- service.yaml
- ingress.yaml

32
apps/paperless/pvc.yaml Normal file
View file

@ -0,0 +1,32 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: paperless-data
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: longhorn
resources:
requests:
storage: 2Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: paperless-media
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: longhorn
resources:
requests:
storage: 50Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: paperless-consume
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: longhorn
resources:
requests:
storage: 5Gi

View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: paperless
spec:
selector:
app: paperless
ports:
- name: http
port: 80
targetPort: http

View file

@ -0,0 +1,39 @@
# Task queue for Paperless. Nothing in it needs to survive a restart.
apiVersion: apps/v1
kind: Deployment
metadata:
name: valkey
spec:
replicas: 1
selector:
matchLabels:
app: valkey
template:
metadata:
labels:
app: valkey
spec:
containers:
- name: valkey
image: valkey/valkey:8.1.10-alpine
ports:
- name: redis
containerPort: 6379
resources:
requests:
cpu: 10m
memory: 32Mi
limits:
memory: 128Mi
---
apiVersion: v1
kind: Service
metadata:
name: valkey
spec:
selector:
app: valkey
ports:
- name: redis
port: 6379
targetPort: redis

View file

@ -0,0 +1,38 @@
# Nightly pg_dumpall streamed into restic on LXC 105, then a ping to the
# "Backup – Postgres (k3s)" Push monitor in Uptime Kuma.
# Suspended until postgres-backup-secrets exists (README, "Postgres backups").
apiVersion: batch/v1
kind: CronJob
metadata:
name: postgres-backup
spec:
suspend: true
schedule: "45 2 * * *"
timeZone: Europe/Paris
concurrencyPolicy: Forbid
jobTemplate:
spec:
backoffLimit: 1
template:
spec:
restartPolicy: Never
containers:
- name: backup
image: postgres:17.11-alpine
envFrom:
- secretRef:
name: postgres-secrets
- secretRef:
name: postgres-backup-secrets
command:
- /bin/sh
- -ec
- |
set -o pipefail
apk add --no-cache restic curl >/dev/null
restic cat config >/dev/null 2>&1 || restic init
export PGPASSWORD="$POSTGRES_PASSWORD"
pg_dumpall -h postgres -U postgres \
| restic backup --stdin --stdin-filename pg_dumpall.sql --host k3s-postgres
restic forget --host k3s-postgres --keep-daily 7 --keep-weekly 4 --keep-monthly 3 --prune
curl -fsS -m 10 -o /dev/null "$KUMA_PUSH_URL"

View file

@ -0,0 +1,14 @@
#!/bin/sh
# Runs once, on the first start with an empty data directory. One role and one
# database per app; passwords come from postgres-secrets.
# Adding an app later: run the same CREATE ROLE / CREATE DATABASE by hand
# (kubectl -n postgres exec -it postgres-0 -- psql -U postgres).
set -e
for app in wikijs paperless linkwarden firefly hedgedoc; do
var=$(echo "$app" | tr a-z A-Z)_DB_PASSWORD
eval pass=\$$var
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" <<SQL
CREATE ROLE $app LOGIN PASSWORD '$pass';
CREATE DATABASE $app OWNER $app;
SQL
done

View file

@ -0,0 +1,13 @@
# Shared Postgres for the apps that need one (wikijs, paperless, linkwarden,
# firefly, hedgedoc). Reached as postgres.postgres.svc:5432.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- sealed-secret.yaml
- statefulset.yaml
- service.yaml
- backup-cronjob.yaml
configMapGenerator:
- name: postgres-init
files:
- init/10-app-databases.sh

View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: postgres
spec:
selector:
app: postgres
ports:
- name: postgres
port: 5432
targetPort: postgres

View file

@ -0,0 +1,56 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres
spec:
serviceName: postgres
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:17.11-alpine
ports:
- name: postgres
containerPort: 5432
envFrom:
- secretRef:
name: postgres-secrets
env:
# Subdirectory: the volume's root holds ext4's lost+found.
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
volumeMounts:
- name: data
mountPath: /var/lib/postgresql/data
- name: init
mountPath: /docker-entrypoint-initdb.d
readinessProbe:
exec:
command: ["pg_isready", "-U", "postgres"]
periodSeconds: 10
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
memory: 1Gi
volumes:
- name: init
configMap:
name: postgres-init
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: longhorn
resources:
requests:
storage: 10Gi

View file

@ -0,0 +1,38 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: privatebin
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: privatebin
template:
metadata:
labels:
app: privatebin
spec:
securityContext:
# The image runs as nobody:www-data (65534:82).
fsGroup: 82
containers:
- name: privatebin
image: privatebin/nginx-fpm-alpine:2.0.6
ports:
- name: http
containerPort: 8080
volumeMounts:
- name: data
mountPath: /srv/data
resources:
requests:
cpu: 10m
memory: 32Mi
limits:
memory: 128Mi
volumes:
- name: data
persistentVolumeClaim:
claimName: privatebin-data

View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: privatebin
spec:
ingressClassName: traefik
rules:
- host: paste.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: privatebin
port:
name: http

View file

@ -0,0 +1,8 @@
# Encrypted pastebin. https://paste.un-oeil.fr
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- pvc.yaml
- deployment.yaml
- service.yaml
- ingress.yaml

10
apps/privatebin/pvc.yaml Normal file
View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: privatebin-data
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: longhorn
resources:
requests:
storage: 1Gi

View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: privatebin
spec:
selector:
app: privatebin
ports:
- name: http
port: 80
targetPort: http

View file

@ -0,0 +1,36 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: searxng
spec:
replicas: 1
selector:
matchLabels:
app: searxng
template:
metadata:
labels:
app: searxng
spec:
containers:
- name: searxng
image: searxng/searxng:2026.10.4-d48c4b555
ports:
- name: http
containerPort: 8080
envFrom:
- secretRef:
name: searxng-secrets
env:
- name: SEARXNG_BASE_URL
value: https://search.un-oeil.fr/
readinessProbe:
httpGet:
path: /healthz
port: http
resources:
requests:
cpu: 50m
memory: 128Mi
limits:
memory: 512Mi

18
apps/searxng/ingress.yaml Normal file
View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: searxng
spec:
ingressClassName: traefik
rules:
- host: search.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: searxng
port:
name: http

View file

@ -0,0 +1,8 @@
# Private metasearch, stateless. https://search.un-oeil.fr
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- sealed-secret.yaml
- deployment.yaml
- service.yaml
- ingress.yaml

11
apps/searxng/service.yaml Normal file
View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: searxng
spec:
selector:
app: searxng
ports:
- name: http
port: 80
targetPort: http

View file

@ -0,0 +1,34 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: stirling-pdf
spec:
replicas: 1
selector:
matchLabels:
app: stirling-pdf
template:
metadata:
labels:
app: stirling-pdf
spec:
containers:
- name: stirling-pdf
image: stirlingtools/stirling-pdf:3.1.0
ports:
- name: http
containerPort: 8080
env:
- name: SYSTEM_DEFAULTLOCALE
value: fr-FR
readinessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 30
resources:
requests:
cpu: 100m
memory: 512Mi
limits:
memory: 2Gi

View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: stirling-pdf
spec:
ingressClassName: traefik
rules:
- host: pdf.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: stirling-pdf
port:
name: http

View file

@ -0,0 +1,7 @@
# PDF toolkit. Files are processed in memory, nothing is kept. https://pdf.un-oeil.fr
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment.yaml
- service.yaml
- ingress.yaml

View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: stirling-pdf
spec:
selector:
app: stirling-pdf
ports:
- name: http
port: 80
targetPort: http

View file

@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: vikunja
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: vikunja
template:
metadata:
labels:
app: vikunja
spec:
securityContext:
fsGroup: 1000
containers:
- name: vikunja
image: vikunja/vikunja:2.7.0
ports:
- name: http
containerPort: 3456
envFrom:
- secretRef:
name: vikunja-secrets
env:
- name: VIKUNJA_SERVICE_PUBLICURL
value: https://tasks.un-oeil.fr/
- name: VIKUNJA_SERVICE_TIMEZONE
value: Europe/Paris
# Turn off once your account exists (README).
- name: VIKUNJA_SERVICE_ENABLEREGISTRATION
value: "true"
- name: VIKUNJA_DATABASE_TYPE
value: sqlite
- name: VIKUNJA_DATABASE_PATH
value: /app/vikunja/files/vikunja.db
volumeMounts:
- name: data
mountPath: /app/vikunja/files
resources:
requests:
cpu: 20m
memory: 64Mi
limits:
memory: 256Mi
volumes:
- name: data
persistentVolumeClaim:
claimName: vikunja-data

18
apps/vikunja/ingress.yaml Normal file
View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: vikunja
spec:
ingressClassName: traefik
rules:
- host: tasks.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: vikunja
port:
name: http

View file

@ -0,0 +1,9 @@
# Tasks / projects, SQLite. https://tasks.un-oeil.fr
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- sealed-secret.yaml
- pvc.yaml
- deployment.yaml
- service.yaml
- ingress.yaml

10
apps/vikunja/pvc.yaml Normal file
View file

@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: vikunja-data
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: longhorn
resources:
requests:
storage: 5Gi

11
apps/vikunja/service.yaml Normal file
View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: vikunja
spec:
selector:
app: vikunja
ports:
- name: http
port: 80
targetPort: http

View file

@ -0,0 +1,45 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: wikijs
spec:
replicas: 1
selector:
matchLabels:
app: wikijs
template:
metadata:
labels:
app: wikijs
spec:
containers:
- name: wikijs
image: ghcr.io/requarks/wiki:2.5.314
ports:
- name: http
containerPort: 3000
envFrom:
- secretRef:
name: wikijs-secrets
env:
- name: DB_TYPE
value: postgres
- name: DB_HOST
value: postgres.postgres.svc
- name: DB_PORT
value: "5432"
- name: DB_USER
value: wikijs
- name: DB_NAME
value: wikijs
readinessProbe:
httpGet:
path: /healthz
port: http
initialDelaySeconds: 20
resources:
requests:
cpu: 50m
memory: 256Mi
limits:
memory: 768Mi

18
apps/wikijs/ingress.yaml Normal file
View file

@ -0,0 +1,18 @@
# Reached through Caddy (LXC 100) -> Traefik on 10.0.0.141-143:80.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: wikijs
spec:
ingressClassName: traefik
rules:
- host: wiki.un-oeil.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: wikijs
port:
name: http

View file

@ -0,0 +1,8 @@
# Wiki, data in the shared Postgres. First visit runs the setup wizard. https://wiki.un-oeil.fr
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- sealed-secret.yaml
- deployment.yaml
- service.yaml
- ingress.yaml

11
apps/wikijs/service.yaml Normal file
View file

@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: wikijs
spec:
selector:
app: wikijs
ports:
- name: http
port: 80
targetPort: http

37
cluster/longhorn.yaml Normal file
View file

@ -0,0 +1,37 @@
# Longhorn: replicated block storage on the workers' 200 GB disk (sdb, mounted
# at /var/lib/longhorn by scripts/prep-worker.sh). Masters are tainted, so
# Longhorn only runs on the workers.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: longhorn
namespace: argocd
spec:
project: default
source:
repoURL: https://charts.longhorn.io
chart: longhorn
targetRevision: 1.13.0
helm:
valuesObject:
# The pre-upgrade hook job doesn't work under Argo CD.
preUpgradeChecker:
jobEnabled: false
persistence:
# local-path stays the k3s default; apps ask for longhorn by name.
defaultClass: false
defaultClassReplicaCount: 2
defaultSettings:
defaultDataPath: /var/lib/longhorn
defaultReplicaCount: 2
destination:
server: https://kubernetes.default.svc
namespace: longhorn-system
syncPolicy:
automated:
# No prune: a bad commit must not be able to delete the storage layer.
prune: false
selfHeal: true
syncOptions:
- CreateNamespace=true
- ServerSideApply=true

View file

@ -0,0 +1,26 @@
# Sealed Secrets controller: decrypts the SealedSecrets committed in apps/.
# Installed as kube-system/sealed-secrets-controller, the name and namespace
# kubeseal looks for by default.
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: sealed-secrets
namespace: argocd
spec:
project: default
source:
repoURL: https://bitnami.github.io/sealed-secrets
chart: sealed-secrets
targetRevision: 2.20.0
helm:
valuesObject:
fullnameOverride: sealed-secrets-controller
destination:
server: https://kubernetes.default.svc
namespace: kube-system
syncPolicy:
automated:
# No prune: deleting the controller loses its key, and every sealed
# secret in the repo becomes unreadable. Back the key up (README).
prune: false
selfHeal: true

View file

@ -0,0 +1,19 @@
# Tweaks to the Traefik that k3s bundles (infra/traefik/).
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: traefik-config
namespace: argocd
spec:
project: default
source:
repoURL: http://10.0.0.14:3000/un-oeil/argocd.git
targetRevision: main
path: infra/traefik
destination:
server: https://kubernetes.default.svc
namespace: kube-system
syncPolicy:
automated:
prune: true
selfHeal: true

View file

@ -0,0 +1,16 @@
# Trust X-Forwarded-For from Caddy (10.0.0.10), so apps see the real client IP
# instead of Caddy's. Requests reach Traefik through ServiceLB, which rewrites
# the source to a node or pod address, hence the two ranges.
apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
name: traefik
namespace: kube-system
spec:
valuesContent: |-
ports:
web:
forwardedHeaders:
trustedIPs:
- 10.0.0.0/24
- 10.42.0.0/16

35
scripts/prep-worker.sh Executable file
View file

@ -0,0 +1,35 @@
#!/usr/bin/env bash
# Longhorn prerequisites on one k3s worker. Run on each worker (141-143):
# ssh un-oeil@10.0.0.141 'sudo bash -s' < scripts/prep-worker.sh
#
# Formats /dev/sdb, the worker's own empty 200 GB disk. On the Proxmox host
# that disk is the zvol hdd-mirror/vm-disks/vm-14x-disk-0, separate from
# /hdd-mirror/vzdump-backups and hdd-mirror/restic-repo. The script stops if
# sdb already has a filesystem or partitions.
set -euo pipefail
DISK=/dev/sdb
MNT=/var/lib/longhorn
[ "$(lsblk -dno SIZE "$DISK" | tr -d " ")" = "200G" ] || { echo "$DISK is not the 200G Longhorn disk, stopping."; exit 1; }
if [ -n "$(blkid -o value -s TYPE "$DISK" 2>/dev/null)" ] || [ "$(lsblk -no NAME "$DISK" | wc -l)" -gt 1 ]; then
if findmnt -no SOURCE "$MNT" | grep -q "^$DISK$"; then
echo "$DISK already mounted on $MNT, skipping the disk part."
else
echo "$DISK already has data and isn't mounted on $MNT, stopping."; exit 1
fi
else
mkfs.ext4 -L longhorn "$DISK"
mkdir -p "$MNT"
echo "LABEL=longhorn $MNT ext4 defaults,noatime 0 2" >> /etc/fstab
mount "$MNT"
fi
apt-get update -qq
apt-get install -y -qq open-iscsi nfs-common
systemctl enable --now iscsid
modprobe iscsi_tcp
echo iscsi_tcp > /etc/modules-load.d/longhorn.conf
# multipathd grabs Longhorn's devices if it's running.
systemctl disable --now multipathd.service multipathd.socket 2>/dev/null || true
df -h "$MNT"; systemctl is-active iscsid

82
scripts/seal-secrets.sh Executable file
View file

@ -0,0 +1,82 @@
#!/usr/bin/env bash
# Generates random passwords for every app and writes them as SealedSecrets
# (apps/<app>/sealed-secret.yaml), which are safe to commit.
#
# Needs: kubectl + kubeseal, KUBECONFIG pointing at the cluster, and the
# sealed-secrets controller running (cluster/sealed-secrets.yaml synced).
#
# Existing files are never overwritten: Postgres only reads its passwords on
# the very first start, so regenerating them would lock the apps out.
# To rotate one app's secret, delete its file, rerun, and change the password
# in Postgres by hand.
#
# Optional, for the nightly Postgres backup (apps/postgres/backup-cronjob.yaml):
# RESTIC_REPOSITORY=rest:http://k3s-postgres:<pw>@10.0.0.15:8000/k3s-postgres \
# RESTIC_PASSWORD=... KUMA_PUSH_URL=https://status.un-oeil.fr/api/push/... \
# scripts/seal-secrets.sh
set -euo pipefail
cd "$(dirname "$0")/.."
rand() { openssl rand -hex "${1:-24}"; }
# seal <app> <secret-name> <file> KEY=VALUE...
seal() {
local app=$1 name=$2 out=apps/$1/$3; shift 3
if [ -e "$out" ]; then echo "skip $out (exists)"; return; fi
local args=()
for kv in "$@"; do args+=(--from-literal="$kv"); done
kubectl create secret generic "$name" -n "$app" "${args[@]}" --dry-run=client -o yaml \
| kubeseal --format yaml > "$out"
echo "wrote $out"
}
# Passwords shared between Postgres and the apps.
WIKIJS=$(rand); PAPERLESS=$(rand); LINKWARDEN=$(rand); FIREFLY=$(rand); HEDGEDOC=$(rand)
# If Postgres already has its passwords, a DB app missing its file would get a
# new password Postgres doesn't know.
if [ -e apps/postgres/sealed-secret.yaml ]; then
for a in wikijs paperless linkwarden firefly hedgedoc; do
if [ ! -e apps/$a/sealed-secret.yaml ]; then
echo "apps/$a/sealed-secret.yaml is missing but Postgres already has its password."
echo "Set it by hand: ALTER ROLE $a PASSWORD '...'; then seal the same value. Aborting."
exit 1
fi
done
fi
seal postgres postgres-secrets sealed-secret.yaml \
POSTGRES_PASSWORD="$(rand)" \
WIKIJS_DB_PASSWORD="$WIKIJS" PAPERLESS_DB_PASSWORD="$PAPERLESS" \
LINKWARDEN_DB_PASSWORD="$LINKWARDEN" FIREFLY_DB_PASSWORD="$FIREFLY" \
HEDGEDOC_DB_PASSWORD="$HEDGEDOC"
seal wikijs wikijs-secrets sealed-secret.yaml DB_PASS="$WIKIJS"
seal paperless paperless-secrets sealed-secret.yaml \
PAPERLESS_DBPASS="$PAPERLESS" PAPERLESS_SECRET_KEY="$(rand 32)" \
PAPERLESS_ADMIN_PASSWORD="$(rand 12)"
seal linkwarden linkwarden-secrets sealed-secret.yaml \
DATABASE_URL="postgresql://linkwarden:$LINKWARDEN@postgres.postgres.svc:5432/linkwarden" \
NEXTAUTH_SECRET="$(rand 32)"
# Firefly wants exactly 32 characters for both.
seal firefly firefly-secrets sealed-secret.yaml \
APP_KEY="$(rand 16)" DB_PASSWORD="$FIREFLY" STATIC_CRON_TOKEN="$(rand 16)"
seal hedgedoc hedgedoc-secrets sealed-secret.yaml \
CMD_DB_URL="postgres://hedgedoc:$HEDGEDOC@postgres.postgres.svc:5432/hedgedoc" \
CMD_SESSION_SECRET="$(rand 32)"
seal vikunja vikunja-secrets sealed-secret.yaml VIKUNJA_SERVICE_JWTSECRET="$(rand 32)"
seal searxng searxng-secrets sealed-secret.yaml SEARXNG_SECRET="$(rand 32)"
seal n8n n8n-secrets sealed-secret.yaml N8N_ENCRYPTION_KEY="$(rand 32)"
if [ -n "${RESTIC_REPOSITORY:-}" ]; then
seal postgres postgres-backup-secrets sealed-backup-secret.yaml \
RESTIC_REPOSITORY="$RESTIC_REPOSITORY" RESTIC_PASSWORD="${RESTIC_PASSWORD:?}" \
KUMA_PUSH_URL="${KUMA_PUSH_URL:?}"
grep -q sealed-backup-secret.yaml apps/postgres/kustomization.yaml \
|| sed -i 's/^ - sealed-secret.yaml$/&\n - sealed-backup-secret.yaml/' apps/postgres/kustomization.yaml
echo "Now set 'suspend: false' in apps/postgres/backup-cronjob.yaml."
fi
echo
echo "Done. Commit apps/*/sealed-secret.yaml and push."
echo "Paperless admin password, once synced:"
echo " kubectl -n paperless get secret paperless-secrets -o jsonpath='{.data.PAPERLESS_ADMIN_PASSWORD}' | base64 -d; echo"