Skip to content

Commit 986b153

Browse files
committed
feat(ingress): serve replicated wildcard on per-tenant ingress controllers
In operator wildcard mode each tenant's ingress controller now sets default-ssl-certificate to the wildcard Secret in its own namespace, so a child tenant serves the replicated wildcard instead of falling back to per-host ACME. ingress-nginx reads the default certificate only from its own namespace, and each ingress HelmRelease renders in the namespace that owns the controller, so the reference stays same-namespace for the root and every child alike. Assisted-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 60738e1 commit 986b153

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

‎packages/extra/ingress/templates/nginx-ingress.yaml‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,18 @@ spec:
5151
{{- /*
5252
Operator-supplied wildcard mode. Serve the pre-existing
5353
wildcard Secret as the default SSL certificate so per-host
54-
ACME certs are unnecessary. Only the publishing controller
55-
(Release.Namespace == expose-ingress) gets the flag: the
56-
Secret lives in that namespace and ingress-nginx must read it
57-
from its own namespace, so child-tenant controllers cannot
58-
point at it. The reference is therefore always same-namespace.
54+
ACME certs are unnecessary. ingress-nginx can only read a
55+
default-ssl-certificate Secret from its own namespace, so the
56+
reference is always same-namespace: the publishing controller
57+
reads the operator-created Secret in tenant-root, and every
58+
child-tenant controller reads the replica that the platform
59+
controller mirrors into that tenant namespace. Each ingress
60+
HelmRelease renders only in the namespace that owns the
61+
controller, so .Release.Namespace is always the right place.
5962
*/}}
60-
{{- if and $wildcardSecret (eq .Release.Namespace $exposeIngress) }}
63+
{{- if $wildcardSecret }}
6164
extraArgs:
62-
default-ssl-certificate: "{{ $exposeIngress }}/{{ $wildcardSecret }}"
65+
default-ssl-certificate: "{{ .Release.Namespace }}/{{ $wildcardSecret }}"
6366
{{- end }}
6467
resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 10 }}
6568
ingressClassResource:

‎packages/extra/ingress/tests/default_ssl_certificate_test.yaml‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ release:
77
namespace: tenant-root
88

99
# When the operator supplies a wildcard Secret
10-
# (_cluster.wildcard-secret-name), the publishing tenant's ingress
11-
# controller must serve it as the default SSL certificate so per-host
12-
# ACME certs are no longer needed. The reference is same-namespace
13-
# (publishing namespace == controller namespace), and the flag is set
14-
# only on the publishing controller — child-tenant controllers cannot
15-
# read a Secret from another namespace, so they must NOT get the flag.
10+
# (_cluster.wildcard-secret-name), each tenant ingress controller serves
11+
# it as the default SSL certificate so per-host ACME certs are no longer
12+
# needed. The reference is always same-namespace: the publishing
13+
# controller reads the operator-created Secret in its own namespace, and
14+
# a child-tenant controller reads the replica the platform controller
15+
# mirrors into that tenant namespace. ingress-nginx can only read a
16+
# default-ssl-certificate Secret from its own namespace, so the flag
17+
# points at .Release.Namespace in every case.
1618

1719
tests:
1820
- it: sets default-ssl-certificate on the publishing controller when wildcard is set
@@ -33,7 +35,7 @@ tests:
3335
- notExists:
3436
path: spec.values.ingress-nginx.controller.extraArgs.default-ssl-certificate
3537

36-
- it: does not set default-ssl-certificate on a non-publishing tenant controller
38+
- it: points a child-tenant controller at its own-namespace wildcard replica
3739
release:
3840
name: ingress
3941
namespace: tenant-foo
@@ -42,5 +44,6 @@ tests:
4244
expose-ingress: tenant-root
4345
wildcard-secret-name: wildcard-tls
4446
asserts:
45-
- notExists:
47+
- equal:
4648
path: spec.values.ingress-nginx.controller.extraArgs.default-ssl-certificate
49+
value: tenant-foo/wildcard-tls

0 commit comments

Comments
 (0)