Skip to content

Commit f3b5fcd

Browse files
committed
NE-2411: Add template field to DNS operator
1 parent 1f2fa3f commit f3b5fcd

21 files changed

Lines changed: 3570 additions & 2 deletions

features.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
| ClusterAPIComputeInstall| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | | | | |
1010
| ClusterAPIControlPlaneInstall| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | | | | |
1111
| ClusterUpdatePreflight| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | | | | |
12+
| DNSTemplatePlugin| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | | | | |
1213
| Example2| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | | | | |
1314
| ExternalOIDCExternalClaimsSourcing| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | | | | |
1415
| ExternalSnapshotMetadata| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | | | | |

features/features.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,14 @@ var (
257257
enable(inTechPreviewNoUpgrade(), inDevPreviewNoUpgrade()).
258258
mustRegister()
259259

260+
FeatureGateDNSTemplatePlugin = newFeatureGate("DNSTemplatePlugin").
261+
reportProblemsToJiraComponent("dns").
262+
contactPerson("grzpiotrowski").
263+
productScope(ocpSpecific).
264+
enhancementPR("https://github.com/openshift/enhancements/pull/1936").
265+
enable(inDevPreviewNoUpgrade()).
266+
mustRegister()
267+
260268
FeatureGateImageModeStatusReporting = newFeatureGate("ImageModeStatusReporting").
261269
reportProblemsToJiraComponent("MachineConfigOperator").
262270
contactPerson("ijanssen").

openapi/generated_openapi/zz_generated.openapi.go

Lines changed: 92 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operator/v1/types_dns.go

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ type DNSSpec struct {
116116
// 30 seconds or as noted in the respective Corefile for your version of OpenShift.
117117
// +optional
118118
Cache DNSCache `json:"cache,omitempty"`
119+
120+
// template is an optional configuration for custom DNS query handling via the CoreDNS template plugin.
121+
// The template defines how to handle queries matching specific zones and query types.
122+
//
123+
// The template applies to all domains (custom domains from spec.servers and the cluster domain)
124+
// to ensure consistent DNS resolution across all paths.
125+
//
126+
// When this field is not set, no template plugin configuration is added to CoreDNS.
127+
//
128+
// +optional
129+
// +openshift:enable:FeatureGate=DNSTemplatePlugin
130+
Template *Template `json:"template,omitempty"`
119131
}
120132

121133
// DNSCache defines the fields for configuring DNS caching.
@@ -467,6 +479,93 @@ const (
467479
DNSAvailable = "Available"
468480
)
469481

482+
// QueryType represents DNS query types supported by templates.
483+
// +kubebuilder:validation:Enum=AAAA
484+
type QueryType string
485+
486+
const (
487+
// QueryTypeAAAA represents IPv6 address records (AAAA).
488+
QueryTypeAAAA QueryType = "AAAA"
489+
)
490+
491+
// QueryClass represents DNS query classes supported by templates.
492+
// Valid value is "IN".
493+
// +kubebuilder:validation:Enum=IN
494+
type QueryClass string
495+
496+
const (
497+
// QueryClassIN represents the Internet class.
498+
QueryClassIN QueryClass = "IN"
499+
)
500+
501+
// ResponseCode represents DNS response codes.
502+
// +kubebuilder:validation:Enum=NOERROR
503+
type ResponseCode string
504+
505+
const (
506+
// ResponseCodeNOERROR indicates a successful DNS query with or without answer records.
507+
ResponseCodeNOERROR ResponseCode = "NOERROR"
508+
)
509+
510+
// Template defines a template for custom DNS query handling via the CoreDNS template plugin.
511+
// Template enables filtering or custom responses for DNS queries matching specific zones and query types.
512+
// +openshift:enable:FeatureGate=DNSTemplatePlugin
513+
type Template struct {
514+
// zones specifies the DNS zones this template applies to.
515+
// Each zone must be a valid DNS name as defined in RFC 1123.
516+
// The special zone "." matches all domains (catch-all).
517+
// Multiple zones can be specified to apply the same template actions to multiple domains.
518+
//
519+
// Note: root zone (".") includes cluster domain (cluster.local); use specific zones to avoid impacting IPv6 queries in IPv6 or dual-stack clusters.
520+
//
521+
// Examples:
522+
// - ["."] matches all domains (catch-all for global AAAA filtering)
523+
// - ["example.com"] matches only example.com and its subdomains
524+
// - ["example.com", "test.com"] matches both domains and their subdomains
525+
//
526+
// +kubebuilder:validation:Required
527+
// +kubebuilder:validation:MinItems=1
528+
// +required
529+
Zones []string `json:"zones"`
530+
531+
// queryType specifies the DNS query type to match.
532+
//
533+
// +kubebuilder:validation:Required
534+
// +kubebuilder:default=AAAA
535+
// +required
536+
QueryType QueryType `json:"queryType"`
537+
538+
// queryClass specifies the DNS query class to match.
539+
//
540+
// +kubebuilder:validation:Required
541+
// +kubebuilder:default=IN
542+
// +required
543+
QueryClass QueryClass `json:"queryClass"`
544+
545+
// actions defines a list of actions to apply to matching queries.
546+
//
547+
// +kubebuilder:validation:Required
548+
// +kubebuilder:validation:MinItems=1
549+
// +required
550+
Actions []TemplateAction `json:"actions"`
551+
}
552+
553+
// TemplateAction defines how to construct a DNS response for queries matching the template.
554+
type TemplateAction struct {
555+
// rcode is the DNS response code to return.
556+
// Valid values are "NOERROR".
557+
//
558+
// When set, the template returns a response with no answer records. For AAAA filtering,
559+
// this means IPv6 address queries return successfully but with no IPv6 addresses,
560+
// causing clients to fall back to IPv4 (A record) queries.
561+
//
562+
// +kubebuilder:validation:Required
563+
// +kubebuilder:validation:Enum=NOERROR
564+
// +kubebuilder:default=NOERROR
565+
// +required
566+
Rcode ResponseCode `json:"rcode"`
567+
}
568+
470569
// DNSStatus defines the observed status of the DNS.
471570
type DNSStatus struct {
472571
// clusterIP is the service IP through which this DNS is made available.

0 commit comments

Comments
 (0)