feat(source): add ACME DNS-01 delegation CNAME wrapper#6548
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @norman-zon! |
|
Hi @norman-zon. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
b8e1bac to
b9e6053
Compare
Add an opt-in source wrapper that generates ACME DNS-01 delegation CNAME records (_acme-challenge.<hostname>) for every A/AAAA/CNAME endpoint discovered from sources, pointing at a target rendered from a configurable Go template. This lets ACME clients such as cert-manager solve DNS-01 challenges with write access limited to a dedicated challenge zone instead of production application zones. New flags: - --acme-cname-delegation-target-template (enables the feature) - --acme-cname-delegation-domain-filter - --acme-cname-delegation-ttl Behaviour: - one delegation CNAME per hostname (A+AAAA and wildcard+apex dedup) - wildcard hostnames map to the challenge name without the wildcard label (*.app.example.com -> _acme-challenge.app.example.com) - explicitly defined _acme-challenge.* endpoints take precedence - resource label and object references are carried over; ownership TXT records are handled by the registry as usual - startup validation: CNAME must be in --managed-record-types, flag consistency checks, warning when combined with --regex-domain-filter Signed-off-by: Norman Stetter <85173861+norman-zon@users.noreply.github.com>
b9e6053 to
f261dce
Compare
|
/easycla |
What does it do ?
Adds an opt-in source wrapper that generates ACME DNS-01 delegation CNAME records for every hostname discovered from sources. When enabled, each A/AAAA/CNAME endpoint (e.g. from Ingress, Service, or Gateway API routes) additionally gets a managed record:
New flags:
--acme-cname-delegation-target-template— Go template for the CNAME target (e.g.{{ .HostnameWithoutWildcard }}.acme.example.net); setting it enables the feature, following the same pattern as--nat64-networks--acme-cname-delegation-domain-filter— restrict generation to matching domain suffixes (repeatable)--acme-cname-delegation-ttl— TTL for the generated CNAMEs; falls back to--min-ttl/ provider defaultBehaviour:
*.app.example.com→_acme-challenge.app.example.com), matchinghow ACME validates wildcard certificates_acme-challenge.*endpoints (e.g. via DNSEndpoint) always take precedence — the wrapper never generates a record for achallenge name a source already provides--managed-record-types, the domain-filter/TTL flags require the template flag, and a warning is logged when combined with--regex-domain-filter(the regex must also match the generated names)Implemented as a source wrapper in
source/wrappers/(modeled on the PTR and NAT64 wrappers), placed before the post-processor so--min-ttlapplies to the generated records. The target template reuses the shared template function set from--fqdn-templatevia a new exportedtemplate.Parsehelper.Testing: unit tests for the wrapper (wildcard, dedup, domain filter, TTL, precedence, template failure modes, error propagation), the wrapperwiring, flag parsing, and validation; the kind-based e2e script now also enables the feature and verifies the delegation CNAME resolves via CoreDNS.
Deliberately deferred as follow-ups to keep this PR reviewable: per-resource annotation opt-in/out (needs ProviderSpecific plumbing through sources like the PTR
record-typemechanism) and restricting generation by source type.Fixes #6535
Motivation
Many organizations use cert-manager with DNS-01 challenges but do not want the ACME client to have write access to production application zones. The established pattern (delegated domains for DNS-01) is to CNAME the challenge name into a dedicated zone that the ACME client may write to, so its credentials are scoped to e.g.
acme.example.netinstead ofexample.com.ExternalDNS already discovers every hostname that needs regular DNS records, so it is in the right position to create the matching delegationCNAMEs — the alternatives (Terraform for dynamic hostnames, a
DNSEndpointper application, or a custom controller/Kyverno policy) either don't scale for self-service Ingress/HTTPRoute hostnames or duplicate logic ExternalDNS already has. See #6535 for the full discussion.The feature is strictly opt-in and does not change existing record generation by default.
More