Skip to content

Commit fc6aa9a

Browse files
authored
feat: Support ExternalName Services (#3759)
feat: Support ExternalName Services Problem: NGF does not support routing to services outside the cluster Solution: Add support for ExternalName type Services
1 parent 5688ba8 commit fc6aa9a

36 files changed

+1883
-132
lines changed

apis/v1alpha2/nginxproxy_types.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ type NginxProxySpec struct {
9494
// +kubebuilder:validation:Minimum=1
9595
// +kubebuilder:validation:Maximum=65535
9696
WorkerConnections *int32 `json:"workerConnections,omitempty"`
97+
// DNSResolver specifies the DNS resolver configuration for external name resolution.
98+
// This enables support for routing to ExternalName Services.
99+
//
100+
// +optional
101+
DNSResolver *DNSResolver `json:"dnsResolver,omitempty"`
97102
}
98103

99104
// Telemetry specifies the OpenTelemetry configuration.
@@ -355,6 +360,61 @@ type NginxPlus struct {
355360
AllowedAddresses []NginxPlusAllowAddress `json:"allowedAddresses,omitempty"`
356361
}
357362

363+
// DNSResolver specifies the DNS resolver configuration for NGINX.
364+
// This enables dynamic DNS resolution for ExternalName Services.
365+
// Corresponds to the NGINX resolver directive: https://nginx.org/en/docs/http/ngx_http_core_module.html#resolver
366+
type DNSResolver struct {
367+
// Timeout specifies the timeout for name resolution.
368+
//
369+
// +optional
370+
Timeout *v1alpha1.Duration `json:"timeout,omitempty"`
371+
372+
// CacheTTL specifies how long to cache DNS responses.
373+
//
374+
// +optional
375+
CacheTTL *v1alpha1.Duration `json:"cacheTTL,omitempty"`
376+
377+
// DisableIPv6 disables IPv6 lookups.
378+
// If not specified, or set to false, IPv6 lookups will be enabled.
379+
//
380+
// +optional
381+
DisableIPv6 *bool `json:"disableIPv6,omitempty"`
382+
383+
// Addresses specifies the list of DNS server addresses.
384+
// Each address can be an IP address or hostname.
385+
// Example: [{"type": "IPAddress", "value": "8.8.8.8"}, {"type": "Hostname", "value": "dns.google"}]
386+
//
387+
// +kubebuilder:validation:MinItems=1
388+
// +kubebuilder:validation:MaxItems=16
389+
Addresses []DNSResolverAddress `json:"addresses"`
390+
}
391+
392+
// DNSResolverAddress specifies the address type and value for a DNS resolver address.
393+
type DNSResolverAddress struct {
394+
// Type specifies the type of address.
395+
Type DNSResolverAddressType `json:"type"`
396+
397+
// Value specifies the address value.
398+
// When Type is "IPAddress", this must be a valid IPv4 or IPv6 address.
399+
// When Type is "Hostname", this must be a valid hostname.
400+
//
401+
// +kubebuilder:validation:MinLength=1
402+
// +kubebuilder:validation:MaxLength=253
403+
Value string `json:"value"`
404+
}
405+
406+
// DNSResolverAddressType specifies the type of DNS resolver address.
407+
// +kubebuilder:validation:Enum=IPAddress;Hostname
408+
type DNSResolverAddressType string
409+
410+
const (
411+
// DNSResolverIPAddressType specifies that the address is an IP address.
412+
DNSResolverIPAddressType DNSResolverAddressType = "IPAddress"
413+
414+
// DNSResolverHostnameType specifies that the address is a hostname.
415+
DNSResolverHostnameType DNSResolverAddressType = "Hostname"
416+
)
417+
358418
// NginxPlusAllowAddress specifies the address type and value for an NginxPlus allow address.
359419
type NginxPlusAllowAddress struct {
360420
// Type specifies the type of address.

apis/v1alpha2/zz_generated.deepcopy.go

Lines changed: 55 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/nginx-gateway-fabric/values.schema.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,62 @@
126126
"required": [],
127127
"type": "boolean"
128128
},
129+
"dnsResolver": {
130+
"description": "DNSResolver specifies the DNS resolver configuration for external name resolution. This enables support for routing to ExternalName Services.",
131+
"properties": {
132+
"addresses": {
133+
"description": "List of DNS server addresses. Each address specifies a type and value.",
134+
"items": {
135+
"properties": {
136+
"type": {
137+
"description": "Type specifies the type of address.",
138+
"enum": [
139+
"IPAddress",
140+
"Hostname"
141+
],
142+
"required": [],
143+
"type": "string"
144+
},
145+
"value": {
146+
"description": "Value specifies the address value.",
147+
"maxItems": 253,
148+
"minItems": 1,
149+
"required": [],
150+
"type": "string"
151+
}
152+
},
153+
"required": [
154+
"type",
155+
"value"
156+
],
157+
"type": "object"
158+
},
159+
"maxItems": 16,
160+
"minItems": 1,
161+
"required": [],
162+
"type": "array"
163+
},
164+
"cacheTTL": {
165+
"description": "CacheTTL specifies how long to cache DNS responses.",
166+
"pattern": "^\\d+[smhd]?$",
167+
"required": [],
168+
"type": "string"
169+
},
170+
"disableIPv6": {
171+
"description": "DisableIPv6 disables DisableIPv6 lookups. If not specified, or set to false, IPv6 lookups will be enabled.",
172+
"required": [],
173+
"type": "boolean"
174+
},
175+
"timeout": {
176+
"description": "Timeout specifies the timeout for name resolution.",
177+
"pattern": "^\\d+[smhd]?$",
178+
"required": [],
179+
"type": "string"
180+
}
181+
},
182+
"required": [],
183+
"type": "object"
184+
},
129185
"ipFamily": {
130186
"description": "IPFamily specifies the IP family to be used by the NGINX.",
131187
"enum": [

charts/nginx-gateway-fabric/values.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,43 @@ nginx:
462462
# minimum: 1
463463
# maximum: 65535
464464
# description: The number of worker connections for NGINX. Default is 1024.
465+
# dnsResolver:
466+
# type: object
467+
# description: DNSResolver specifies the DNS resolver configuration for external name resolution. This enables support for routing to ExternalName Services.
468+
# properties:
469+
# addresses:
470+
# type: array
471+
# description: List of DNS server addresses. Each address specifies a type and value.
472+
# items:
473+
# type: object
474+
# properties:
475+
# type:
476+
# type: string
477+
# enum:
478+
# - IPAddress
479+
# - Hostname
480+
# description: Type specifies the type of address.
481+
# value:
482+
# type: string
483+
# minItems: 1
484+
# maxItems: 253
485+
# description: Value specifies the address value.
486+
# required:
487+
# - type
488+
# - value
489+
# minItems: 1
490+
# maxItems: 16
491+
# timeout:
492+
# type: string
493+
# description: Timeout specifies the timeout for name resolution.
494+
# pattern: ^\d+[smhd]?$
495+
# cacheTTL:
496+
# type: string
497+
# description: CacheTTL specifies how long to cache DNS responses.
498+
# pattern: ^\d+[smhd]?$
499+
# disableIPv6:
500+
# type: boolean
501+
# description: DisableIPv6 disables DisableIPv6 lookups. If not specified, or set to false, IPv6 lookups will be enabled.
465502
# @schema
466503
# -- The configuration for the data plane that is contained in the NginxProxy resource. This is applied globally to all Gateways
467504
# managed by this instance of NGINX Gateway Fabric.

config/crd/bases/gateway.nginx.org_nginxproxies.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,57 @@ spec:
6565
introduces security risks as described in Gateway API GEP-3567.
6666
If not specified, defaults to false (validation enabled).
6767
type: boolean
68+
dnsResolver:
69+
description: |-
70+
DNSResolver specifies the DNS resolver configuration for external name resolution.
71+
This enables support for routing to ExternalName Services.
72+
properties:
73+
addresses:
74+
description: |-
75+
Addresses specifies the list of DNS server addresses.
76+
Each address can be an IP address or hostname.
77+
Example: [{"type": "IPAddress", "value": "8.8.8.8"}, {"type": "Hostname", "value": "dns.google"}]
78+
items:
79+
description: DNSResolverAddress specifies the address type and
80+
value for a DNS resolver address.
81+
properties:
82+
type:
83+
description: Type specifies the type of address.
84+
enum:
85+
- IPAddress
86+
- Hostname
87+
type: string
88+
value:
89+
description: |-
90+
Value specifies the address value.
91+
When Type is "IPAddress", this must be a valid IPv4 or IPv6 address.
92+
When Type is "Hostname", this must be a valid hostname.
93+
maxLength: 253
94+
minLength: 1
95+
type: string
96+
required:
97+
- type
98+
- value
99+
type: object
100+
maxItems: 16
101+
minItems: 1
102+
type: array
103+
cacheTTL:
104+
description: CacheTTL specifies how long to cache DNS responses.
105+
pattern: ^[0-9]{1,4}(ms|s|m|h)?$
106+
type: string
107+
disableIPv6:
108+
description: |-
109+
DisableIPv6 disables IPv6 lookups.
110+
If not specified, or set to false, IPv6 lookups will be enabled.
111+
type: boolean
112+
timeout:
113+
description: Timeout specifies the timeout for name resolution.
114+
pattern: ^[0-9]{1,4}(ms|s|m|h)?$
115+
type: string
116+
required:
117+
- addresses
118+
type: object
68119
ipFamily:
69120
default: dual
70121
description: |-

deploy/crds.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,57 @@ spec:
650650
introduces security risks as described in Gateway API GEP-3567.
651651
If not specified, defaults to false (validation enabled).
652652
type: boolean
653+
dnsResolver:
654+
description: |-
655+
DNSResolver specifies the DNS resolver configuration for external name resolution.
656+
This enables support for routing to ExternalName Services.
657+
properties:
658+
addresses:
659+
description: |-
660+
Addresses specifies the list of DNS server addresses.
661+
Each address can be an IP address or hostname.
662+
Example: [{"type": "IPAddress", "value": "8.8.8.8"}, {"type": "Hostname", "value": "dns.google"}]
663+
items:
664+
description: DNSResolverAddress specifies the address type and
665+
value for a DNS resolver address.
666+
properties:
667+
type:
668+
description: Type specifies the type of address.
669+
enum:
670+
- IPAddress
671+
- Hostname
672+
type: string
673+
value:
674+
description: |-
675+
Value specifies the address value.
676+
When Type is "IPAddress", this must be a valid IPv4 or IPv6 address.
677+
When Type is "Hostname", this must be a valid hostname.
678+
maxLength: 253
679+
minLength: 1
680+
type: string
681+
required:
682+
- type
683+
- value
684+
type: object
685+
maxItems: 16
686+
minItems: 1
687+
type: array
688+
cacheTTL:
689+
description: CacheTTL specifies how long to cache DNS responses.
690+
pattern: ^[0-9]{1,4}(ms|s|m|h)?$
691+
type: string
692+
disableIPv6:
693+
description: |-
694+
DisableIPv6 disables IPv6 lookups.
695+
If not specified, or set to false, IPv6 lookups will be enabled.
696+
type: boolean
697+
timeout:
698+
description: Timeout specifies the timeout for name resolution.
699+
pattern: ^[0-9]{1,4}(ms|s|m|h)?$
700+
type: string
701+
required:
702+
- addresses
703+
type: object
653704
ipFamily:
654705
default: dual
655706
description: |-

0 commit comments

Comments
 (0)