caddy: deploy caddy as edge reverse proxy (on kube)

This commit is contained in:
2026-05-08 00:48:55 +02:00
parent cbf7842e8b
commit d5831fd1e3
11 changed files with 285 additions and 1 deletions

View File

@@ -53,6 +53,7 @@ updates:
- "/kubernetes/personal/photoprism" - "/kubernetes/personal/photoprism"
- "/kubernetes/production/umami" - "/kubernetes/production/umami"
- "/kubernetes/system/blocky" - "/kubernetes/system/blocky"
- "/kubernetes/system/caddy"
- "/kubernetes/system/coredns" - "/kubernetes/system/coredns"
- "/kubernetes/system/csi-driver-nfs" - "/kubernetes/system/csi-driver-nfs"
- "/kubernetes/system/external-dns" - "/kubernetes/system/external-dns"

View File

@@ -3,7 +3,7 @@ creation_rules:
encrypted_regex: ^(password|value|ssh-key|api-key|user|username|privateKey|clientSecret|clientId|apiKey|extraArgs.*|.*Secret.*|extraEnvVars|.*SECRET.*|.*secret.*|key|.*Password|.*\.ya?ml)$ encrypted_regex: ^(password|value|ssh-key|api-key|user|username|privateKey|clientSecret|clientId|apiKey|extraArgs.*|.*Secret.*|extraEnvVars|.*SECRET.*|.*secret.*|key|.*Password|.*\.ya?ml)$
pgp: DC6910268E657FF70BA7EC289974494E76938DDC pgp: DC6910268E657FF70BA7EC289974494E76938DDC
- path_regex: .*.yaml - path_regex: .*.yaml
encrypted_regex: ^(data|stringData)$ encrypted_regex: ^(data|stringData|.*.key|.*.crt)$
pgp: DC6910268E657FF70BA7EC289974494E76938DDC pgp: DC6910268E657FF70BA7EC289974494E76938DDC
- path_regex: .*.env$ - path_regex: .*.env$
input_type: dotenv input_type: dotenv

View File

@@ -0,0 +1,69 @@
# Caddy Routes - External ConfigMap
# This file contains all route definitions, imported by the main Caddyfile.
# Edit this file to add/modify routes.
#
# Certificate files are mounted from the caddy-certificates Secret
# at /etc/caddy/certs/
apiVersion: v1
kind: ConfigMap
metadata:
name: caddy-routes
namespace: caddy
labels:
app.kubernetes.io/name: caddy
app.kubernetes.io/component: routes
data:
Caddyfile: |
vhaudiquet.fr {
tls /etc/caddy/certs/vhaudiquet-fr.crt /etc/caddy/certs/vhaudiquet-fr.key
reverse_proxy 10.1.2.212:80
}
*.vhaudiquet.fr {
tls /etc/caddy/certs/wildcard-vhaudiquet-fr.crt /etc/caddy/certs/wildcard-vhaudiquet-fr.key
# Kubernetes services (via Traefik)
@authentik host authentik.vhaudiquet.fr
@auth-nook host auth-nook.vhaudiquet.fr
@nook-mg host n.vhaudiquet.fr
@nook host nook.vhaudiquet.fr
@sse-nook host sse-nook.vhaudiquet.fr
@gitea host git.vhaudiquet.fr
@flux-wh host flux-webhook.vhaudiquet.fr
@umami host umami.vhaudiquet.fr
handle @authentik { reverse_proxy traefik.traefik.svc.cluster.local:80 }
handle @auth-nook { reverse_proxy traefik.traefik.svc.cluster.local:80 }
handle @nook-mg { reverse_proxy traefik.traefik.svc.cluster.local:80 }
handle @nook { reverse_proxy traefik.traefik.svc.cluster.local:80 }
handle @sse-nook { reverse_proxy traefik.traefik.svc.cluster.local:80 }
handle @gitea { reverse_proxy traefik.traefik.svc.cluster.local:80 }
handle @flux-wh { reverse_proxy traefik.traefik.svc.cluster.local:80 }
handle @umami { reverse_proxy traefik.traefik.svc.cluster.local:80 }
# Docker VM services (via Traefik)
@alexscript host alexscript.vhaudiquet.fr
@clips host clips.vhaudiquet.fr
@jellyfin host flix.vhaudiquet.fr
@mail host mail.vhaudiquet.fr
handle @alexscript { reverse_proxy 10.1.2.212:80 }
handle @clips { reverse_proxy 10.1.2.212:80 }
handle @jellyfin { reverse_proxy 10.1.2.212:80 }
handle @mail { reverse_proxy 10.1.2.212:80 }
}
semery.fr {
tls /etc/caddy/certs/semery-fr.crt /etc/caddy/certs/semery-fr.key
reverse_proxy 10.1.2.212:80
}
buildpath.win {
tls /etc/caddy/certs/buildpath-win.crt /etc/caddy/certs/buildpath-win.key
reverse_proxy 10.1.2.212:80
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,15 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: caddy
resources:
- namespace.yaml
- repository.yaml
- release.yaml
- certificates-secret.yaml
- caddyfile.yaml
secretGenerator:
- name: caddy-values
files:
- values.yaml=values.yaml
configurations:
- kustomizeconfig.yaml

View File

@@ -0,0 +1,6 @@
nameReference:
- kind: Secret
version: v1
fieldSpecs:
- path: spec/valuesFrom/name
kind: HelmRelease

View File

@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
name: caddy
labels:
app.kubernetes.io/name: caddy
app.kubernetes.io/component: edge-proxy

View File

@@ -0,0 +1,19 @@
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: caddy
namespace: caddy
spec:
interval: 1m
chart:
spec:
sourceRef:
kind: HelmRepository
name: caddy
namespace: caddy
chart: caddy
interval: 1m
version: "0.7.1"
valuesFrom:
- kind: Secret
name: caddy-values

View File

@@ -0,0 +1,8 @@
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: caddy
namespace: caddy
spec:
interval: 1m
url: https://charts.alekc.dev/

View File

@@ -0,0 +1,104 @@
# Caddy Edge Proxy
replicaCount: 2
# Listen on standard HTTP port
listenPort: 80
# Enable HTTPS
https:
enabled: true
port: 443
image:
repository: caddy
pullPolicy: IfNotPresent
tagSuffix: ""
tag: 2.11.2
service:
type: LoadBalancer
annotations:
io.cilium/lb-ipam-ips: 10.1.2.152
externalTrafficPolicy: Local
# Disable ingress - Caddy IS the edge proxy
ingress:
enabled: false
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 256Mi
podSecurityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
health:
path: /
port: 9999
# Extra volumes: certificates + external routes ConfigMap
volumes:
- name: certificates
secret:
secretName: ENC[AES256_GCM,data:hpxK4mqVNwVRWutC4ufnqhzu,iv:D/7vhjkr5buSFJ42UeGKicPJA7YxHhv+vmakFFE11Vk=,tag:AExbVZIQu+wrUb5jq86toA==,type:str]
optional: ENC[AES256_GCM,data:y19uLw==,iv:S5VEP6p7GspKtXeTDumHy1xJ0yW1qu/t4yqy3bhlZSE=,tag:mkZiVVboLoOhGd1EcE9PaA==,type:bool]
- name: routes
configMap:
name: caddy-routes
# Extra volume mounts
volumeMounts:
- name: certificates
mountPath: /etc/caddy/certs
readOnly: true
- name: routes
mountPath: /etc/caddy/routes
readOnly: true
# Caddy configuration
config:
debug: false
# Global options (goes inside the global {} block)
global: |
auto_https off
# The main Caddyfile content - imports routes from external ConfigMap
# This keeps routes in a separate, easily editable file
caddyFile: |
import /etc/caddy/routes/Caddyfile
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/name: caddy
topologyKey: kubernetes.io/hostname
sops:
lastmodified: "2026-05-07T22:47:47Z"
mac: ENC[AES256_GCM,data:LQqoe/wDLAUJWLiEGoID3CSI4bQmdVaroAkq7Kk9Ullt85X3VmYMOrLXjn1Qew95rpG6gB9Bl7rvv0J7mUDJtewhfkSsSXKTYJAcn4VVoNGZ3PZu9/w5HNvOqDhTkXBWKEgQK4+HMKKEhW8iQ5aJ+oTAEZfKsp9k8+mqgHId100=,iv:E/v+fY9iKM9W9NFSGNtiJV6ZeaAb2Fy2hGDgOBwmFyU=,tag:JOD69j8SUS5339+zrV9L4g==,type:str]
pgp:
- created_at: "2026-05-07T22:47:46Z"
enc: |-
-----BEGIN PGP MESSAGE-----
hQIMA7uy4qQr71wiARAAt5P8/X84OYKnWvKc5qRpwHNQwbfqrB/SHkX82oJ8ZlXJ
/vlKVDOBrlntePt4cyKT6c3Ubw4xDj/1U3PkvM44AXSRHH8E5dSUI+5T/0+SBlfU
6XlkF6cpng/ydMvImTAi3+8bmC3yHE/NEegreldjFj7l2hdFuvfyOp7pmE//Ljox
D7tkq9v1/IlvPfeAY0xIEotr1nb41OEhM7OhPQjtGUeufD0eCUhCQaZSo+CjTrf2
cG+eE/O2jCLNjWJ33wK1AHtHX1mlyzW8sRkRVgg511G8iquFjD11ZuDZPEIC8Yle
idftTlPh0ZTOGXcfDVn5Pq9dgkZ3K6ufhvEb8mw0NrPsysY21PdDaIzLo58b4t2m
akJ1xCciwsQDorKfFjpG7gFzV1KvMzw/KjEUFxg5JfKaFGTPhgsf50OiM6VPf4gP
cTS5QNewdnbnzHE756PkZqfqdt6Tt9xqji8r72PwTSUy6yaK/lV9owAIZ6V2yTdt
l3DckDp0HsU/w98fabiX9CsrJUWeUfioElw2ibXWcXNHmqPoFl1Bf/AbF20t6P9p
+1J0vMu6ONsBGv2Flmle2Ya7OQbZF4lQB4dQLUBDKdZArsB5Sspm3Rf+4iP9qUF+
Pr/OotbiaOLsEZybIf+L2d5ON4zCbNAU5VbpfWMKH0AsPcIH5Ruw7d/OutAGZOvS
XAGAEBjVlZ2IRU6CSPJDG/9TqBHyBHfriV+BoGlKlXbPMoJAZI2wX1o7+M6S65ho
aiR70aCo2kIgFvxxBeY1FxtB0DB8Zeoul7ovvhKIq2u9s7X/OSIa0X5dm6sZ
=fg1O
-----END PGP MESSAGE-----
fp: DC6910268E657FF70BA7EC289974494E76938DDC
encrypted_regex: ^(password|value|ssh-key|api-key|user|username|privateKey|clientSecret|clientId|apiKey|extraArgs.*|.*Secret.*|extraEnvVars|.*SECRET.*|.*secret.*|key|.*Password|.*\.ya?ml)$
version: 3.10.2

View File

@@ -6,3 +6,4 @@ spec:
blocks: blocks:
- cidr: "10.1.2.171/32" - cidr: "10.1.2.171/32"
- cidr: "10.1.2.148/32" - cidr: "10.1.2.148/32"
- cidr: "10.1.2.152/32"