Skip to content

Commit

Permalink
Added support for ALL DNS lookup family (projectcontour#4909)
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Choudhary <contactvishaltech@gmail.com>
Signed-off-by: Sunjay Bhatia <sunjayb@vmware.com>
Co-authored-by: Sunjay Bhatia <sunjayb@vmware.com>
Signed-off-by: yy <yang.yang@daocloud.io>
  • Loading branch information
2 people authored and yangyy93 committed Feb 16, 2023
1 parent 1ccc34a commit 4466463
Show file tree
Hide file tree
Showing 22 changed files with 217 additions and 76 deletions.
2 changes: 2 additions & 0 deletions apis/projectcontour/v1/httpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ type RemoteJWKS struct {
// When configured as "v4", the DNS resolver will only perform a lookup
// for addresses in the IPv4 family. If "v6" is configured, the DNS resolver
// will only perform a lookup for addresses in the IPv6 family.
// If "all" is configured, the DNS resolver
// will perform a lookup for addresses in both the IPv4 and IPv6 family.
// If "auto" is configured, the DNS resolver will first perform a lookup
// for addresses in the IPv6 family and fallback to a lookup for addresses
// in the IPv4 family. If not specified, the Contour-wide setting defined
Expand Down
9 changes: 7 additions & 2 deletions apis/projectcontour/v1alpha1/contourconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ const (
IPv4ClusterDNSFamily ClusterDNSFamilyType = "v4"
// DNS lookups will only attempt v6 queries.
IPv6ClusterDNSFamily ClusterDNSFamilyType = "v6"
// DNS lookups will attempt both v4 and v6 queries.
AllClusterDNSFamily ClusterDNSFamilyType = "all"
)

// ClusterParameters holds various configurable cluster values.
Expand All @@ -540,13 +542,16 @@ type ClusterParameters struct {
// will only perform a lookup for addresses in the IPv6 family.
// If AUTO is configured, the DNS resolver will first perform a lookup
// for addresses in the IPv6 family and fallback to a lookup for addresses
// in the IPv4 family.
// in the IPv4 family. If ALL is specified, the DNS resolver will perform a lookup for
// both IPv4 and IPv6 families, and return all resolved addresses.
// When this is used, Happy Eyeballs will be enabled for upstream connections.
// Refer to Happy Eyeballs Support for more information.
// Note: This only applies to externalName clusters.
//
// See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
// for more information.
//
// Values: `auto` (default), `v4`, `v6`.
// Values: `auto` (default), `v4`, `v6`, `all`.
//
// Other values will produce an error.
// +optional
Expand Down
2 changes: 1 addition & 1 deletion apis/projectcontour/v1alpha1/contourconfig_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (x XDSServerType) Validate() error {

func (d ClusterDNSFamilyType) Validate() error {
switch d {
case AutoClusterDNSFamily, IPv4ClusterDNSFamily, IPv6ClusterDNSFamily:
case AutoClusterDNSFamily, IPv4ClusterDNSFamily, IPv6ClusterDNSFamily, AllClusterDNSFamily:
return nil
default:
return fmt.Errorf("invalid cluster dns family type %q", d)
Expand Down
3 changes: 3 additions & 0 deletions apis/projectcontour/v1alpha1/contourconfig_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ func TestContourConfigurationSpecValidate(t *testing.T) {
c.Envoy.Cluster.DNSLookupFamily = v1alpha1.IPv6ClusterDNSFamily
require.NoError(t, c.Validate())

c.Envoy.Cluster.DNSLookupFamily = v1alpha1.AllClusterDNSFamily
require.NoError(t, c.Validate())

c.Envoy.Cluster.DNSLookupFamily = "foo"
require.Error(t, c.Validate())

Expand Down
2 changes: 2 additions & 0 deletions changelogs/unreleased/4909-Vishal-Chdhry-minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added support for `ALL` DNS lookup family. If `ALL` is specified, the DNS resolver will perform a lookup for both IPv4 and IPv6 families, and return all resolved addresses. When this is used, Happy Eyeballs will be enabled for upstream connections.

2 changes: 1 addition & 1 deletion cmd/contour/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func registerBootstrap(app *kingpin.Application) (*kingpin.CmdClause, *envoy.Boo
bootstrap.Flag("envoy-key-file", "Client key filename for Envoy secure xDS gRPC communication.").Envar("ENVOY_KEY_FILE").StringVar(&config.GrpcClientKey)
bootstrap.Flag("namespace", "The namespace the Envoy container will run in.").Envar("CONTOUR_NAMESPACE").Default("projectcontour").StringVar(&config.Namespace)
bootstrap.Flag("xds-resource-version", "The versions of the xDS resources to request from Contour.").Default("v3").StringVar((*string)(&config.XDSResourceVersion))
bootstrap.Flag("dns-lookup-family", "Defines what DNS Resolution Policy to use for Envoy -> Contour cluster name lookup. Either v4, v6 or auto.").StringVar(&config.DNSLookupFamily)
bootstrap.Flag("dns-lookup-family", "Defines what DNS Resolution Policy to use for Envoy -> Contour cluster name lookup. Either v4, v6, auto, or all.").StringVar(&config.DNSLookupFamily)
bootstrap.Flag("overload-max-heap", "Defines the maximum heap size in bytes until overload manager stops accepting new connections.").Uint64Var(&config.MaximumHeapSizeBytes)
return bootstrap, &config
}
2 changes: 2 additions & 0 deletions cmd/contour/servecontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ func (ctx *serveContext) convertToContourConfigurationSpec() contour_api_v1alpha
dnsLookupFamily = contour_api_v1alpha1.IPv6ClusterDNSFamily
case config.IPv4ClusterDNSFamily:
dnsLookupFamily = contour_api_v1alpha1.IPv4ClusterDNSFamily
case config.AllClusterDNSFamily:
dnsLookupFamily = contour_api_v1alpha1.AllClusterDNSFamily
}

var tracingConfig *contour_api_v1alpha1.TracingConfig
Expand Down
33 changes: 22 additions & 11 deletions examples/contour/01-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,14 @@ spec:
for addresses in the IPv6 family. If AUTO is configured,
the DNS resolver will first perform a lookup for addresses
in the IPv6 family and fallback to a lookup for addresses
in the IPv4 family. Note: This only applies to externalName
clusters. \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
in the IPv4 family. If ALL is specified, the DNS resolver
will perform a lookup for both IPv4 and IPv6 families, and
return all resolved addresses. When this is used, Happy
Eyeballs will be enabled for upstream connections. Refer
to Happy Eyeballs Support for more information. Note: This
only applies to externalName clusters. \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
for more information. \n Values: `auto` (default), `v4`,
`v6`. \n Other values will produce an error."
`v6`, `all`. \n Other values will produce an error."
type: string
type: object
defaultHTTPVersions:
Expand Down Expand Up @@ -3070,10 +3074,15 @@ spec:
perform a lookup for addresses in the IPv6 family. If
AUTO is configured, the DNS resolver will first perform
a lookup for addresses in the IPv6 family and fallback
to a lookup for addresses in the IPv4 family. Note:
This only applies to externalName clusters. \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
to a lookup for addresses in the IPv4 family. If ALL
is specified, the DNS resolver will perform a lookup
for both IPv4 and IPv6 families, and return all resolved
addresses. When this is used, Happy Eyeballs will be
enabled for upstream connections. Refer to Happy Eyeballs
Support for more information. Note: This only applies
to externalName clusters. \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
for more information. \n Values: `auto` (default), `v4`,
`v6`. \n Other values will produce an error."
`v6`, `all`. \n Other values will produce an error."
type: string
type: object
defaultHTTPVersions:
Expand Down Expand Up @@ -5772,11 +5781,13 @@ spec:
will only perform a lookup for addresses in the IPv4
family. If \"v6\" is configured, the DNS resolver
will only perform a lookup for addresses in the IPv6
family. If \"auto\" is configured, the DNS resolver
will first perform a lookup for addresses in the IPv6
family and fallback to a lookup for addresses in the
IPv4 family. If not specified, the Contour-wide setting
defined in the config file or ContourConfiguration
family. If \"all\" is configured, the DNS resolver
will perform a lookup for addresses in both the IPv4
and IPv6 family. If \"auto\" is configured, the DNS
resolver will first perform a lookup for addresses
in the IPv6 family and fallback to a lookup for addresses
in the IPv4 family. If not specified, the Contour-wide
setting defined in the config file or ContourConfiguration
applies (defaults to \"auto\"). \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
for more information."
enum:
Expand Down
33 changes: 22 additions & 11 deletions examples/render/contour-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,14 @@ spec:
for addresses in the IPv6 family. If AUTO is configured,
the DNS resolver will first perform a lookup for addresses
in the IPv6 family and fallback to a lookup for addresses
in the IPv4 family. Note: This only applies to externalName
clusters. \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
in the IPv4 family. If ALL is specified, the DNS resolver
will perform a lookup for both IPv4 and IPv6 families, and
return all resolved addresses. When this is used, Happy
Eyeballs will be enabled for upstream connections. Refer
to Happy Eyeballs Support for more information. Note: This
only applies to externalName clusters. \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
for more information. \n Values: `auto` (default), `v4`,
`v6`. \n Other values will produce an error."
`v6`, `all`. \n Other values will produce an error."
type: string
type: object
defaultHTTPVersions:
Expand Down Expand Up @@ -3280,10 +3284,15 @@ spec:
perform a lookup for addresses in the IPv6 family. If
AUTO is configured, the DNS resolver will first perform
a lookup for addresses in the IPv6 family and fallback
to a lookup for addresses in the IPv4 family. Note:
This only applies to externalName clusters. \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
to a lookup for addresses in the IPv4 family. If ALL
is specified, the DNS resolver will perform a lookup
for both IPv4 and IPv6 families, and return all resolved
addresses. When this is used, Happy Eyeballs will be
enabled for upstream connections. Refer to Happy Eyeballs
Support for more information. Note: This only applies
to externalName clusters. \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
for more information. \n Values: `auto` (default), `v4`,
`v6`. \n Other values will produce an error."
`v6`, `all`. \n Other values will produce an error."
type: string
type: object
defaultHTTPVersions:
Expand Down Expand Up @@ -5982,11 +5991,13 @@ spec:
will only perform a lookup for addresses in the IPv4
family. If \"v6\" is configured, the DNS resolver
will only perform a lookup for addresses in the IPv6
family. If \"auto\" is configured, the DNS resolver
will first perform a lookup for addresses in the IPv6
family and fallback to a lookup for addresses in the
IPv4 family. If not specified, the Contour-wide setting
defined in the config file or ContourConfiguration
family. If \"all\" is configured, the DNS resolver
will perform a lookup for addresses in both the IPv4
and IPv6 family. If \"auto\" is configured, the DNS
resolver will first perform a lookup for addresses
in the IPv6 family and fallback to a lookup for addresses
in the IPv4 family. If not specified, the Contour-wide
setting defined in the config file or ContourConfiguration
applies (defaults to \"auto\"). \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
for more information."
enum:
Expand Down
33 changes: 22 additions & 11 deletions examples/render/contour-gateway-provisioner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,14 @@ spec:
for addresses in the IPv6 family. If AUTO is configured,
the DNS resolver will first perform a lookup for addresses
in the IPv6 family and fallback to a lookup for addresses
in the IPv4 family. Note: This only applies to externalName
clusters. \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
in the IPv4 family. If ALL is specified, the DNS resolver
will perform a lookup for both IPv4 and IPv6 families, and
return all resolved addresses. When this is used, Happy
Eyeballs will be enabled for upstream connections. Refer
to Happy Eyeballs Support for more information. Note: This
only applies to externalName clusters. \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
for more information. \n Values: `auto` (default), `v4`,
`v6`. \n Other values will produce an error."
`v6`, `all`. \n Other values will produce an error."
type: string
type: object
defaultHTTPVersions:
Expand Down Expand Up @@ -3084,10 +3088,15 @@ spec:
perform a lookup for addresses in the IPv6 family. If
AUTO is configured, the DNS resolver will first perform
a lookup for addresses in the IPv6 family and fallback
to a lookup for addresses in the IPv4 family. Note:
This only applies to externalName clusters. \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
to a lookup for addresses in the IPv4 family. If ALL
is specified, the DNS resolver will perform a lookup
for both IPv4 and IPv6 families, and return all resolved
addresses. When this is used, Happy Eyeballs will be
enabled for upstream connections. Refer to Happy Eyeballs
Support for more information. Note: This only applies
to externalName clusters. \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
for more information. \n Values: `auto` (default), `v4`,
`v6`. \n Other values will produce an error."
`v6`, `all`. \n Other values will produce an error."
type: string
type: object
defaultHTTPVersions:
Expand Down Expand Up @@ -5786,11 +5795,13 @@ spec:
will only perform a lookup for addresses in the IPv4
family. If \"v6\" is configured, the DNS resolver
will only perform a lookup for addresses in the IPv6
family. If \"auto\" is configured, the DNS resolver
will first perform a lookup for addresses in the IPv6
family and fallback to a lookup for addresses in the
IPv4 family. If not specified, the Contour-wide setting
defined in the config file or ContourConfiguration
family. If \"all\" is configured, the DNS resolver
will perform a lookup for addresses in both the IPv4
and IPv6 family. If \"auto\" is configured, the DNS
resolver will first perform a lookup for addresses
in the IPv6 family and fallback to a lookup for addresses
in the IPv4 family. If not specified, the Contour-wide
setting defined in the config file or ContourConfiguration
applies (defaults to \"auto\"). \n See https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto.html#envoy-v3-api-enum-config-cluster-v3-cluster-dnslookupfamily
for more information."
enum:
Expand Down
Loading

0 comments on commit 4466463

Please sign in to comment.