From 49cd3e023eb672aa25d2b374111a63ed3c88a2a6 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 13 Nov 2026 22:32:28 +0100 Subject: [PATCH] Forgejo + Longhorn mit Let's Encrypt, Traefik-Import --- main.tf | 23 +++++++++++++++++++++-- talos/coredns-hosts.md | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 talos/coredns-hosts.md diff --git a/main.tf b/main.tf index 8e59844..6bdea91 100644 --- a/main.tf +++ b/main.tf @@ -50,6 +50,12 @@ variable "longhorn_host" { default = "longhorn.boday.lan" } +# Wer das Longhorn-Dashboard erreichen darf (Quell-IPs, wie sie bei Traefik ankommen) +variable "longhorn_allowed_cidrs" { + type = list(string) + default = ["172.25.64.0/24", "172.25.65.0/24"] +} + # BasicAuth für Longhorn als htpasswd-Zeile, z.B.: htpasswd -nbB admin 'geheim' variable "longhorn_basic_auth" { type = string @@ -167,6 +173,12 @@ resource "helm_release" "traefik" { metadata = { name = "longhorn-auth", namespace = "longhorn-system" } spec = { basicAuth = { secret = "longhorn-basic-auth" } } }, + { + apiVersion = "traefik.io/v1alpha1" + kind = "Middleware" + metadata = { name = "longhorn-allowlist", namespace = "longhorn-system" } + spec = { ipAllowList = { sourceRange = var.longhorn_allowed_cidrs } } + }, { apiVersion = "networking.k8s.io/v1" kind = "Ingress" @@ -174,11 +186,17 @@ resource "helm_release" "traefik" { name = "longhorn" namespace = "longhorn-system" annotations = { - "traefik.ingress.kubernetes.io/router.middlewares" = "longhorn-system-longhorn-auth@kubernetescrd" + # Erst IP-Allowlist (nur LAN/DMZ), dann Login + "traefik.ingress.kubernetes.io/router.middlewares" = "longhorn-system-longhorn-allowlist@kubernetescrd,longhorn-system-longhorn-auth@kubernetescrd" + "cert-manager.io/cluster-issuer" = "letsencrypt-prod" } } spec = { ingressClassName = "traefik" + tls = [{ + secretName = "longhorn-tls" + hosts = [var.longhorn_host] + }] rules = [{ host = var.longhorn_host http = { @@ -220,7 +238,8 @@ output "traefik_lb_ip" { value = var.traefik_lb_ip } -# Adopt Traefik into the state again (lost when Consul restarted) +# --- Traefik wieder in den State übernehmen (State ging beim Consul-Neustart verloren) --- +# Nach erfolgreichem Lauf dürfen die Blöcke bleiben oder entfernt werden. import { to = kubernetes_namespace.traefik id = "traefik" diff --git a/talos/coredns-hosts.md b/talos/coredns-hosts.md new file mode 100644 index 0000000..0b93204 --- /dev/null +++ b/talos/coredns-hosts.md @@ -0,0 +1,19 @@ +# CoreDNS-Hosts-Eintrag (manuell gepflegt) + +Pods im Cluster (u.a. die Selbstprüfung von cert-manager) sollen die eigenen öffentlichen Namen +direkt auf den Traefik-Ingress auflösen, statt über die öffentliche IP 46.4.148.66 (kein Hairpin-NAT). + +`kubectl -n kube-system edit configmap coredns`, im Block `.:53 {` nach `errors`: + +``` + hosts { + 172.25.64.200 boday-it.ch www.boday-it.ch forgejo.boday-it.ch longhorn.boday-it.ch + fallthrough + } +``` + +Danach: `kubectl -n kube-system rollout restart deployment coredns` + +Achtung: `talosctl upgrade-k8s` kann die ConfigMap überschreiben. Nach jedem Kubernetes-Upgrade prüfen: +`kubectl run dnstest --rm -i --restart=Never --image=busybox -- nslookup boday-it.ch` → 172.25.64.200 +Neue öffentliche Hostnamen auf Talos hier ergänzen.