Files
home-network-k3s-impl/apps/wave-1/semaphore.yaml
T
jakman85andClaude Opus 4.8 36a1a4e1f9 refactor(apps): split monolithic apps Kustomization into dependency waves
Replaces the single `apps` Flux Kustomization with dependency-ordered waves
(apps-wave-0..2) so a crashlooping workload isolates to its wave + downstream
instead of stalling the entire app tier. Parallel within a wave, ordered across.

- catalog/render.py: compute waves by longest dependency-path depth over the
  ServiceDefinition `dependencies:` edges (a `<svc>-db` is a leaf, so its
  consumer lands strictly higher — the "DB below consumer" rule falls out of
  longest-path, no special case). `--emit-waves` generates the per-wave
  kustomizations + Flux CRs; `--wave-layout` places renders into the right dir.
  wave 0: pihole gitea jackett plex qbittorrent nextcloud-db semaphore-db
  wave 1: sonarr radarr nextcloud semaphore gitea-actions
  wave 2: seerr
- apps/*.yaml -> apps/wave-{0,1,2}/ (byte-identical moves; SOPS files intact).
- clusters/base: apps.yaml removed; apps-wave-{0,1,2}.yaml added (dependsOn
  chain: platform-config -> wave-0 -> wave-1 -> wave-2, prune+wait each).
- clusters/dev: one SOPS decryption patch per wave (load-bearing).
- DESIGN-waves.md: wave table, topology, cutover runbook.

Cutover: preceded by disabling prune on `apps` (1bfb0db) so removing that
object here does not GC its resources; the wave Kustomizations SSA-adopt the
byte-identical manifests in place (no restart, no PVC churn).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-08-26 12:19:00 -05:00

277 lines
6.4 KiB
YAML

---
# Namespace (trust zone; default-deny + policies apply)
apiVersion: v1
kind: Namespace
metadata:
name: semaphore
labels:
homelab.keithjackson.dev/app-namespace: 'true'
gateway-access: shared
annotations:
homelab.keithjackson.dev/backup-policy: daily-offcluster
---
# Default-deny baseline (R-NET-01): deny all, allow only DNS
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny
namespace: semaphore
labels:
homelab.keithjackson.dev/baseline: default-deny
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
ingress: []
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
---
# PVC semaphore-config (R-STATE)
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: semaphore-config
namespace: semaphore
labels:
app.kubernetes.io/name: semaphore
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn
resources:
requests:
storage: 1Gi
---
# Deployment (R-PLAT-02)
apiVersion: apps/v1
kind: Deployment
metadata:
name: semaphore
namespace: semaphore
labels:
app.kubernetes.io/name: semaphore
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app.kubernetes.io/name: semaphore
template:
metadata:
labels:
app.kubernetes.io/name: semaphore
homelab.keithjackson.dev/egress-class: internet
homelab.keithjackson.dev/auth-mode: oidc
annotations:
homelab.keithjackson.dev/auth-mode: oidc
homelab.keithjackson.dev/auth-groups: platform-admins
spec:
containers:
- name: semaphore
image: semaphoreui/semaphore:v2.19.10
ports:
- containerPort: 3000
env:
- name: SEMAPHORE_DB_DIALECT
value: postgres
- name: SEMAPHORE_DB_HOST
value: semaphore-db-rw.semaphore-db.svc.cluster.local
- name: SEMAPHORE_DB_PORT
value: '5432'
- name: SEMAPHORE_DB
value: semaphore
- name: SEMAPHORE_DB_USER
value: semaphore
- name: SEMAPHORE_DB_PASS
valueFrom:
secretKeyRef:
name: semaphore-bootstrap
key: db-password
- name: SEMAPHORE_ADMIN
valueFrom:
secretKeyRef:
name: semaphore-bootstrap
key: admin-username
- name: SEMAPHORE_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: semaphore-bootstrap
key: admin-password
- name: SEMAPHORE_ADMIN_NAME
value: Semaphore Admin
- name: SEMAPHORE_ADMIN_EMAIL
value: [email protected]
- name: SEMAPHORE_ACCESS_KEY_ENCRYPTION
valueFrom:
secretKeyRef:
name: semaphore-bootstrap
key: access-key-encryption
- name: SEMAPHORE_PORT
value: :3000
volumeMounts:
- name: config
mountPath: /etc/semaphore
securityContext:
runAsUser: 1001
runAsGroup: 0
runAsNonRoot: true
fsGroup: 1001
volumes:
- name: config
persistentVolumeClaim:
claimName: semaphore-config
---
# Service
apiVersion: v1
kind: Service
metadata:
name: semaphore
namespace: semaphore
labels:
app.kubernetes.io/name: semaphore
spec:
selector:
app.kubernetes.io/name: semaphore
ports:
- name: port-3000
port: 3000
targetPort: 3000
---
# CiliumNetworkPolicy egress allow (R-NET-02): semaphore-allow-semaphore-db-5432
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
name: semaphore-allow-semaphore-db-5432
namespace: semaphore
labels:
app.kubernetes.io/name: semaphore
spec:
endpointSelector:
matchLabels:
app.kubernetes.io/name: semaphore
egress:
- toEndpoints:
- matchLabels:
app.kubernetes.io/name: semaphore-db
k8s:io.kubernetes.pod.namespace: semaphore-db
toPorts:
- ports:
- port: '5432'
protocol: TCP
---
# CiliumNetworkPolicy gateway-ingress allow (R-NET-01/02): semaphore-allow-gateway-ingress
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
name: semaphore-allow-gateway-ingress
namespace: semaphore
labels:
app.kubernetes.io/name: semaphore
spec:
endpointSelector:
matchLabels:
app.kubernetes.io/name: semaphore
ingress:
- fromEntities:
- ingress
toPorts:
- ports:
- port: '3000'
protocol: TCP
---
# CiliumNetworkPolicy world egress allow (egress class governs the path; R-NET-05): semaphore-allow-internet-egress
apiVersion: cilium.io/v2
kind: CiliumNetworkPolicy
metadata:
name: semaphore-allow-internet-egress
namespace: semaphore
labels:
app.kubernetes.io/name: semaphore
spec:
endpointSelector:
matchLabels:
app.kubernetes.io/name: semaphore
egress:
- toEntities:
- world
---
# HTTPRoute semaphore-3000 (R-TLS/R-DNS)
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: semaphore-3000
namespace: semaphore
labels:
app.kubernetes.io/name: semaphore
annotations:
homelab.keithjackson.dev/auth-mode: oidc
homelab.keithjackson.dev/auth-groups: platform-admins
spec:
parentRefs:
- name: shared
namespace: gateway
sectionName: https
hostnames:
- semaphore.home.keithjackson.dev
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: semaphore
port: 3000
---
# ServiceMonitor (R-OBS-01)
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: semaphore
namespace: semaphore
labels:
release: kube-prometheus-stack
app.kubernetes.io/name: semaphore
spec:
selector:
matchLabels:
app.kubernetes.io/name: semaphore
namespaceSelector:
matchNames:
- semaphore
endpoints:
- port: metrics
interval: 30s
---
# PrometheusRule SLI alerts (R-OBS-01)
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: semaphore-slis
namespace: semaphore
labels:
release: kube-prometheus-stack
app.kubernetes.io/name: semaphore
spec:
groups:
- name: semaphore.slis
rules:
- alert: semaphore-down
expr: up{job="semaphore"} == 0
for: 5m
labels:
severity: critical
service: semaphore
annotations:
summary: semaphore is down
description: 'semaphore has been unreachable for 5m (SLI: up).'