fix: keep the nginx ingress annotations when the ingress controller is traefik

ingress_annotations() treated the two controllers as either/or: choosing traefik dropped the nginx proxy-body-size annotation, so on a cluster routed by nginx the 50 MiB upload cap silently became nginx' 1 MiB default and uploads failed with HTTP 413. An ingress annotation only acts when a controller of that family routes the ingress, so emit both annotation sets always: nginx's size and timeout annotations (plus the rewrite-target null that keeps API paths intact), and the Traefik middleware reference on top when the config says traefik. The Middleware object is created as before.

Version 1.6.2.
This commit is contained in:
Igor
2026-10-09 20:42:49 +03:00
parent 4a267c5336
commit 777fc8aa9a
4 changed files with 24 additions and 19 deletions
+6 -4
View File
@@ -216,13 +216,15 @@ class IngressShaping(unittest.TestCase):
self.assertEqual(a["nginx.ingress.kubernetes.io/proxy-read-timeout"], "3600")
self.assertNotIn("traefik.ingress.kubernetes.io/router.middlewares", a)
def test_traefik_native(self):
def test_traefik_also_keeps_nginx_annotations(self):
# The nginx keys must be present in traefik mode too: while nginx routes the
# ingress they enforce the cap, and they are inert the day Traefik takes over.
a = self.ann({"ingress_controller": "traefik"})
self.assertEqual(a["traefik.ingress.kubernetes.io/router.middlewares"],
"supaspin-2-supa2-buffering@kubernetescrd")
for nginx_key in ("rewrite-target", "proxy-body-size", "proxy-read-timeout",
"proxy-send-timeout"):
self.assertNotIn(f"nginx.ingress.kubernetes.io/{nginx_key}", a)
self.assertIsNone(a["nginx.ingress.kubernetes.io/rewrite-target"])
self.assertEqual(a["nginx.ingress.kubernetes.io/proxy-body-size"], "50m")
self.assertEqual(a["nginx.ingress.kubernetes.io/proxy-read-timeout"], "3600")
self.assertEqual(a["cert-manager.io/cluster-issuer"], "supaspin-letsencrypt")
def test_lets_encrypt_off_drops_cert_manager_annotation(self):