ingress-nginx in apps-in-apps aufnehmen + GeoIP (DB-IP Lite), tv.smokyzone.de nur aus DE

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-25 10:34:49 +01:00
co-authored by Claude Opus 5.5
parent 4ace5801ca
commit 42fa5b0ad8
+136
View File
@@ -142,6 +142,142 @@ applications:
syncOptions: syncOptions:
- CreateNamespace=true - CreateNamespace=true
# ingress-nginx - the only ingress controller. Was created by hand with kubectl; now
# managed here. NOTE: upstream ingress-nginx is retired (no releases since 03/2026) -
# plan a migration (Gateway API / Traefik) eventually.
#
# GeoIP: country database from DB-IP Lite (https://db-ip.com, CC BY 4.0), MaxMind-compatible,
# stored on the node in /var/lib/ingress-geoip so the controller always has a DB even if
# the internet is down at boot (without the file nginx would reject the config that uses
# $geoip2_country_code -> ALL ingresses down). The init container refreshes it when
# possible, the sidecar weekly; nginx reloads it daily (geoip2-autoreload-in-minutes).
# Hosts listed in the $geo_restricted_host map only answer to clients from Germany.
- name: ingress-nginx
enabled: true
source:
repoURL: https://kubernetes.github.io/ingress-nginx
chart: ingress-nginx
targetRevision: "4.15.1"
helm:
values: |
controller:
service:
type: NodePort
nodePorts:
http: 30081
https: 30444
# Also listen on the node's ports 80/443 directly, so LAN/Tailscale URLs need no port.
hostPort:
enabled: true
ports:
http: 80
https: 443
# A hostPort can't be held by two pods: replace the pod instead of surging.
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
extraArgs:
maxmind-edition-ids: GeoLite2-Country
config:
# Real client IP for requests that come through Cloudflare (git, Home Assistant).
# The header is only trusted when the connection itself comes from a Cloudflare
# range, so nobody can spoof it by hitting the public IP directly.
enable-real-ip: "true"
forwarded-for-header: CF-Connecting-IP
proxy-real-ip-cidr: "173.245.48.0/20,103.21.244.0/22,103.22.200.0/22,103.31.4.0/22,141.101.64.0/18,108.162.192.0/18,190.93.240.0/20,188.114.96.0/20,197.234.240.0/22,198.41.128.0/17,162.158.0.0/15,104.16.0.0/13,104.24.0.0/14,172.64.0.0/13,131.0.72.0/22,2400:cb00::/32,2606:4700::/32,2803:f800::/32,2405:b500::/32,2405:8100::/32,2a06:98c0::/29,2c0f:f248::/32"
use-geoip2: "true"
geoip2-autoreload-in-minutes: "1440"
# Geo restriction for publicly exposed hosts: everything not from DE gets 403
# (also unknown/private IPs - LAN/Tailscale use the internal hostnames instead).
http-snippet: |
map $host $geo_restricted_host {
default 0;
tv.smokyzone.de 1;
}
map "$geo_restricted_host:$geoip2_country_code" $geo_block {
default 0;
"~^1:(?!DE$)" 1;
}
server-snippet: |
if ($geo_block) {
return 403;
}
extraVolumes:
- name: geoip
hostPath:
path: /var/lib/ingress-geoip
type: DirectoryOrCreate
extraVolumeMounts:
- name: geoip
mountPath: /etc/ingress-controller/geoip
readOnly: true
extraInitContainers:
- name: geoip-init
image: curlimages/curl:8.23.0
securityContext:
runAsUser: 0
command: ["sh", "-c"]
args:
- |
D=/geoip
fetch() {
for m in $(date -u +%Y-%m) $(date -u -d "@$(( $(date +%s) - 2592000 ))" +%Y-%m); do
if curl -fsSL --retry 3 --max-time 120 -o $D/.dl.gz "https://download.db-ip.com/free/dbip-country-lite-$m.mmdb.gz" \
&& gunzip -c $D/.dl.gz > $D/.dl.mmdb && [ -s $D/.dl.mmdb ]; then
chmod 644 $D/.dl.mmdb && mv $D/.dl.mmdb $D/GeoLite2-Country.mmdb
rm -f $D/.dl.gz; echo "GeoIP: dbip-country-lite-$m"; return 0
fi
done
rm -f $D/.dl.gz $D/.dl.mmdb; return 1
}
fetch && exit 0
if [ -s $D/GeoLite2-Country.mmdb ]; then echo "GeoIP: download failed, keeping existing DB"; exit 0; fi
echo "GeoIP: no database available"; exit 1
volumeMounts:
- name: geoip
mountPath: /geoip
extraContainers:
- name: geoip-update
image: curlimages/curl:8.23.0
securityContext:
runAsUser: 0
command: ["sh", "-c"]
args:
- |
D=/geoip
while true; do
sleep 604800
for m in $(date -u +%Y-%m) $(date -u -d "@$(( $(date +%s) - 2592000 ))" +%Y-%m); do
if curl -fsSL --retry 3 --max-time 120 -o $D/.dl.gz "https://download.db-ip.com/free/dbip-country-lite-$m.mmdb.gz" \
&& gunzip -c $D/.dl.gz > $D/.dl.mmdb && [ -s $D/.dl.mmdb ]; then
chmod 644 $D/.dl.mmdb && mv $D/.dl.mmdb $D/GeoLite2-Country.mmdb; echo "GeoIP updated: $m"; break
fi
done
rm -f $D/.dl.gz $D/.dl.mmdb
done
resources:
requests:
cpu: 1m
memory: 8Mi
limits:
memory: 64Mi
volumeMounts:
- name: geoip
mountPath: /geoip
admissionWebhooks:
enabled: false
destination:
server: https://kubernetes.default.svc
namespace: ingress-nginx
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
# Gitea - Git server for all *-gitops repos (and thus ArgoCD's own source). # Gitea - Git server for all *-gitops repos (and thus ArgoCD's own source).
# Was created by hand with kubectl; now managed here. # Was created by hand with kubectl; now managed here.
# No chart-managed admin: the bootstrap user gitea_admin was deleted, the user's # No chart-managed admin: the bootstrap user gitea_admin was deleted, the user's