Skip to content

Commit 34563ce

Browse files
committed
feat(platform): add opt-in shared wildcard issuance for ingress path
On the default ingress-nginx path (gateway.enabled=false) a DNS-01 solver still minted a per-host ACME certificate for every system service, hitting Let's Encrypt rate limits once a deployment exceeds ~50 endpoints. Add an opt-in publishing.certificates.wildcard toggle (default false) and compute, in apps.yaml, an effective wildcard secret name plus a wildcard-issue signal: when enabled with solver=dns01 and no operator-provided wildcardSecretName, the platform targets one shared wildcard cert (*.<root-host> + <root-host>) instead of per-host certs. Issuance is off by default because a single-label wildcard does not cover a custom service host outside *.<root-host> (e.g. a keycloak ingress.host, harbor host, or grafana host pointed at another domain); enabling it would otherwise switch such a host to the controller's default certificate and serve the wrong certificate. The operator-provided (BYO) name always wins and never triggers issuance; http01 cannot issue wildcards; and the Gateway API path issues its own wildcard via the controller, so all three are excluded. This reuses the existing wildcard-secret-name consumption path, so no per-service ingress template changes are needed. Part of #2811. Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 82b8c46 commit 34563ce

5 files changed

Lines changed: 244 additions & 5 deletions

File tree

‎packages/core/platform/templates/apps.yaml‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,37 @@ stringData:
2424
solver: {{ .Values.publishing.certificates.solver | quote }}
2525
issuer-name: {{ .Values.publishing.certificates.issuerName | quote }}
2626
{{- /*
27-
Operator-supplied wildcard mode. Only the Secret NAME rides this
27+
Wildcard certificate mode. Only the Secret NAME rides this
2828
channel — never the cert/key material (unlike a private key, the
2929
name is not sensitive). When set, the ingress flow points the
3030
root ingress controller's --default-ssl-certificate at it and
3131
drops per-host ACME, and the gateway chart switches the
32-
TenantGateway to certMode=existingSecret. The Secret itself must
33-
be pre-created by the operator in the publishing namespace
34-
(tenant-root). Empty string = ACME issuance as before.
32+
TenantGateway to certMode=existingSecret.
33+
34+
The name comes from one of two sources, with the operator-
35+
provided (BYO) name always winning:
36+
1. publishing.certificates.wildcardSecretName — a Secret the
37+
operator pre-creates in the publishing namespace
38+
(tenant-root). wildcard-issue stays false: the platform
39+
mints nothing.
40+
2. Otherwise, on the ingress-nginx path (gateway.enabled=false)
41+
with solver=dns01 and publishing.certificates.wildcard=true,
42+
the platform issues its own shared wildcard. wildcard-issue
43+
becomes true and the publishing ingress package renders the
44+
Certificate into this Secret name. http01 cannot issue
45+
wildcards, and the Gateway API path issues its own wildcard
46+
via the TenantGateway controller, so both are excluded.
47+
Empty name + wildcard-issue=false = per-host ACME as before.
3548
*/}}
36-
wildcard-secret-name: {{ .Values.publishing.certificates.wildcardSecretName | default "" | quote }}
49+
{{- $byoWildcard := .Values.publishing.certificates.wildcardSecretName | default "" }}
50+
{{- $wildcardSecretName := $byoWildcard }}
51+
{{- $wildcardIssue := false }}
52+
{{- if and (not $byoWildcard) (eq .Values.publishing.certificates.solver "dns01") .Values.publishing.certificates.wildcard (not .Values.gateway.enabled) }}
53+
{{- $wildcardSecretName = "cozystack-wildcard-tls" }}
54+
{{- $wildcardIssue = true }}
55+
{{- end }}
56+
wildcard-secret-name: {{ $wildcardSecretName | quote }}
57+
wildcard-issue: {{ $wildcardIssue | quote }}
3758
{{- /*
3859
DNS-01 solver wiring. Read only when solver=dns01, but the
3960
keys are written unconditionally so a render-time switch from
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
suite: apps.yaml ACME wildcard issuance wiring
2+
3+
templates:
4+
- templates/apps.yaml
5+
6+
release:
7+
name: cozy-platform
8+
namespace: cozy-system
9+
10+
# WS2 / #2400: on the default ingress-nginx path (gateway.enabled=false) a
11+
# DNS-01 solver lets the platform issue ONE shared wildcard certificate
12+
# (*.<root-host> + <root-host>) instead of minting a per-host ACME cert
13+
# for every system service. It is OPT-IN (publishing.certificates.wildcard,
14+
# default false): a single-label wildcard does not cover custom service
15+
# hosts outside *.<root-host>, so leaving it off keeps the safe per-host
16+
# behavior and never switches a dns01 cluster silently on upgrade.
17+
# apps.yaml computes the effective _cluster.wildcard-secret-name and an
18+
# _cluster.wildcard-issue signal the publishing ingress package reads to
19+
# render the Certificate. Operator-provided (BYO) wildcard names always
20+
# win and never trigger issuance; http01 cannot issue wildcards; the
21+
# Gateway API path issues its own wildcard via the controller, so issuance
22+
# here is gated to gateway.enabled=false.
23+
24+
tests:
25+
- it: does not issue a wildcard by default (http01)
26+
asserts:
27+
- matchRegex:
28+
path: stringData["values.yaml"]
29+
pattern: 'wildcard-secret-name:\s*""'
30+
- matchRegex:
31+
path: stringData["values.yaml"]
32+
pattern: 'wildcard-issue:\s*"false"'
33+
34+
- it: does not auto-issue on dns01 unless explicitly opted in
35+
set:
36+
publishing.certificates.solver: dns01
37+
asserts:
38+
- matchRegex:
39+
path: stringData["values.yaml"]
40+
pattern: 'wildcard-secret-name:\s*""'
41+
- matchRegex:
42+
path: stringData["values.yaml"]
43+
pattern: 'wildcard-issue:\s*"false"'
44+
45+
- it: issues a shared wildcard when opted in on the dns01 ingress path
46+
set:
47+
publishing.certificates.solver: dns01
48+
publishing.certificates.wildcard: true
49+
asserts:
50+
- matchRegex:
51+
path: stringData["values.yaml"]
52+
pattern: 'wildcard-secret-name:\s*"cozystack-wildcard-tls"'
53+
- matchRegex:
54+
path: stringData["values.yaml"]
55+
pattern: 'wildcard-issue:\s*"true"'
56+
57+
- it: does not auto-issue on the ingress path when Gateway API is enabled
58+
set:
59+
publishing.certificates.solver: dns01
60+
publishing.certificates.wildcard: true
61+
gateway.enabled: true
62+
asserts:
63+
- matchRegex:
64+
path: stringData["values.yaml"]
65+
pattern: 'wildcard-secret-name:\s*""'
66+
- matchRegex:
67+
path: stringData["values.yaml"]
68+
pattern: 'wildcard-issue:\s*"false"'
69+
70+
- it: operator-provided wildcard secret wins and never triggers issuance
71+
set:
72+
publishing.certificates.solver: dns01
73+
publishing.certificates.wildcard: true
74+
publishing.certificates.wildcardSecretName: byo-wildcard-tls
75+
asserts:
76+
- matchRegex:
77+
path: stringData["values.yaml"]
78+
pattern: 'wildcard-secret-name:\s*"byo-wildcard-tls"'
79+
- matchRegex:
80+
path: stringData["values.yaml"]
81+
pattern: 'wildcard-issue:\s*"false"'
82+
83+
- it: http01 never issues a wildcard even when opted in
84+
set:
85+
publishing.certificates.solver: http01
86+
publishing.certificates.wildcard: true
87+
asserts:
88+
- matchRegex:
89+
path: stringData["values.yaml"]
90+
pattern: 'wildcard-secret-name:\s*""'
91+
- matchRegex:
92+
path: stringData["values.yaml"]
93+
pattern: 'wildcard-issue:\s*"false"'

‎packages/core/platform/values.yaml‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,50 @@ publishing:
199199
certificates:
200200
solver: http01 # "http01" or "dns01"
201201
issuerName: letsencrypt-prod
202+
# Shared wildcard issuance on the default ingress-nginx path
203+
# (gateway.enabled=false). Opt-in, OFF by default. When set to true
204+
# with solver=dns01 and no operator-provided wildcardSecretName, the
205+
# platform issues ONE wildcard Certificate (*.<root-host> +
206+
# <root-host>) via the DNS-01 ClusterIssuer and serves it as the
207+
# ingress controller's default SSL certificate, so system services
208+
# (dashboard, grafana, keycloak, harbor, …) stop minting a per-host
209+
# ACME cert each. This avoids the Let's Encrypt per-domain rate limit
210+
# once a deployment exceeds ~50 endpoints, matching the Gateway API
211+
# path which issues a per-apex wildcard in dns01 mode.
212+
#
213+
# Ignored when solver=http01 (HTTP-01 cannot issue wildcards) and
214+
# when gateway.enabled=true (the TenantGateway controller issues the
215+
# wildcard there).
216+
#
217+
# COVERAGE CAVEAT — same contract as wildcardSecretName below: a
218+
# single-label wildcard *.<root-host> covers <service>.<root-host>
219+
# but NOT a custom service host outside it (e.g. a keycloak
220+
# ingress.host / harbor host / grafana host set to auth.example.com,
221+
# or a nested a.b.<root-host>). When this is true, services whose
222+
# host is not covered fall back to the default SSL certificate and
223+
# would serve the wrong certificate. Only enable it when every
224+
# exposed system service uses a <service>.<root-host> host (the
225+
# default), or provide a covering wildcardSecretName instead. Left
226+
# OFF by default precisely so a dns01 cluster with a custom service
227+
# host is never silently switched on upgrade.
228+
#
229+
# BLAST RADIUS — like wildcardSecretName, the chosen name rides the
230+
# _cluster channel, which every child tenant inherits verbatim. A
231+
# child tenant that inherits the root ingress has nested service
232+
# hosts (<service>.<tenant>.<root-host>) that *.<root-host> does NOT
233+
# cover; enabling this makes those services drop per-host ACME and
234+
# serve the root default certificate too. This is not root-tenant
235+
# scoped — only enable it when child-tenant hosts are also covered
236+
# (or left on the Gateway path). Per-tenant wildcards are tracked
237+
# separately.
238+
#
239+
# FIRST-ISSUANCE WINDOW: when this is turned on, consumers drop their
240+
# per-host certs immediately, but the DNS-01 wildcard takes a few
241+
# minutes to issue. Until the Secret is populated ingress-nginx serves
242+
# its self-signed default cert (browser warning), then self-heals —
243+
# the same delay per-host ACME has on first issue, which an
244+
# operator-provided wildcardSecretName avoids only by pre-existing.
245+
wildcard: false
202246
# Operator-provided wildcard certificate. When set, platform
203247
# services and the root tenant's ingress/Gateway serve under this
204248
# pre-existing TLS Secret instead of minting per-host ACME certs.

‎packages/system/bucket/tests/ingress_wildcard_test.yaml‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,32 @@ tests:
5151
value: letsencrypt-prod
5252
- exists:
5353
path: spec.tls[0].secretName
54+
55+
# WS2 / #2400 child-tenant blast radius, pinned as a contract: the
56+
# wildcard secret name rides _cluster, which packages/apps/tenant copies
57+
# verbatim into every child tenant. A child inheriting the root ingress
58+
# has nested service hosts (<svc>.<tenant>.<root-host>) that a
59+
# single-label *.<root-host> does NOT cover, yet the service still drops
60+
# its per-host cert and falls back to the root default certificate. This
61+
# is the documented reason shared wildcard issuance is opt-in / off by
62+
# default. Here _namespace.host is the child apex (alice.example.org),
63+
# so the bucket host is two labels deep under the wildcard.
64+
- it: nested child-tenant host drops per-host ACME when wildcard mode is active
65+
set:
66+
bucketName: data
67+
_namespace:
68+
host: alice.example.org
69+
ingress: tenant-root
70+
gateway: ""
71+
_cluster:
72+
issuer-name: letsencrypt-prod
73+
solver: dns01
74+
wildcard-secret-name: cozystack-wildcard-tls
75+
asserts:
76+
- equal:
77+
path: spec.rules[0].host
78+
value: data.alice.example.org
79+
- notExists:
80+
path: metadata.annotations["cert-manager.io/cluster-issuer"]
81+
- notExists:
82+
path: spec.tls[0].secretName

‎packages/system/keycloak/tests/ingress_wildcard_test.yaml‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,55 @@ tests:
5050
- equal:
5151
path: spec.tls[0].secretName
5252
value: web-tls
53+
54+
# WS2 / #2400 blocker guard: a custom keycloak host (auth.example.com)
55+
# is outside the platform wildcard *.<root-host>. Because shared
56+
# wildcard issuance is opt-in (publishing.certificates.wildcard,
57+
# default false), a dns01 cluster carries no _cluster.wildcard-secret-name
58+
# and keycloak keeps its own per-host certificate — the controller never
59+
# falls back to a default cert that does not cover this host.
60+
- it: keeps per-host ACME for a custom host on dns01 when wildcard issuance is off
61+
set:
62+
ingress.host: auth.example.com
63+
_cluster:
64+
root-host: example.org
65+
issuer-name: letsencrypt-prod
66+
solver: dns01
67+
expose-ingress: tenant-root
68+
gateway-enabled: "false"
69+
asserts:
70+
- equal:
71+
path: spec.rules[0].host
72+
value: auth.example.com
73+
- equal:
74+
path: metadata.annotations["cert-manager.io/cluster-issuer"]
75+
value: letsencrypt-prod
76+
- equal:
77+
path: spec.tls[0].secretName
78+
value: web-tls
79+
80+
# WS2 / #2400 coverage tradeoff, pinned as a contract: once shared
81+
# wildcard mode is active (_cluster.wildcard-secret-name set), a custom
82+
# host outside *.<root-host> ALSO drops its per-host cert and falls back
83+
# to the default SSL certificate, which does not cover it. This is the
84+
# hazard the publishing.certificates.wildcard values.yaml caveat warns
85+
# about and the reason issuance is opt-in / off by default. Pinning it
86+
# keeps the tradeoff a conscious contract rather than an accident.
87+
- it: custom host drops per-host ACME when wildcard mode is active
88+
set:
89+
ingress.host: auth.example.com
90+
_cluster:
91+
root-host: example.org
92+
issuer-name: letsencrypt-prod
93+
solver: dns01
94+
expose-ingress: tenant-root
95+
gateway-enabled: "false"
96+
wildcard-secret-name: cozystack-wildcard-tls
97+
asserts:
98+
- equal:
99+
path: spec.rules[0].host
100+
value: auth.example.com
101+
- notExists:
102+
path: metadata.annotations["cert-manager.io/cluster-issuer"]
103+
- notExists:
104+
path: spec.tls[0].secretName

0 commit comments

Comments
 (0)