Skip to content

Commit

Permalink
Merge branch 'kubernetes-sigs:master' into fix-gatewayapi-protomatch
Browse files Browse the repository at this point in the history
  • Loading branch information
zs-ko authored Feb 9, 2024
2 parents c787846 + 7311390 commit 9795c0b
Show file tree
Hide file tree
Showing 11 changed files with 368 additions and 219 deletions.
9 changes: 9 additions & 0 deletions docs/tutorials/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,15 @@ Annotations which are specific to AWS.

`external-dns.alpha.kubernetes.io/aws-target-hosted-zone` can optionally be set to the ID of a Route53 hosted zone. This will force external-dns to use the specified hosted zone when creating an ALIAS target.

### aws-zone-match-parent
`aws-zone-match-parent` allows support subdomains within the same zone by using their parent domain, i.e --domain-filter=x.example.com would create a DNS entry for x.example.com (and subdomains thereof).

```yaml
## hosted zone domain: example.com
--domain-filter=x.example.com,example.com
--aws-zone-match-parent
```

## Verify ExternalDNS works (Service example)

Create the following sample application to test that ExternalDNS works.
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/gke.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ ExternalDNS will need permissions to make changes to the Cloud DNS zone. There a

* [Worker Node Service Account](#worker-node-service-account)
* [Static Credentials](#static-credentials)
* [Work Load Identity](#work-load-identity)
* [Workload Identity](#workload-identity)

### Setup Cloud DNS and GKE

Expand Down
21 changes: 21 additions & 0 deletions endpoint/domain_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,24 @@ func (df *DomainFilter) UnmarshalJSON(b []byte) error {
*df = NewRegexDomainFilter(include, exclude)
return nil
}

func (df DomainFilter) MatchParent(domain string) bool {
if matchFilter(df.exclude, domain, false) {
return false
}
if len(df.Filters) == 0 {
return true
}

strippedDomain := strings.ToLower(strings.TrimSuffix(domain, "."))
for _, filter := range df.Filters {
if filter == "" || strings.HasPrefix(filter, ".") {
// We don't check parents if the filter is prefixed with "."
continue
}
if strings.HasSuffix(filter, "."+strippedDomain) {
return true
}
}
return false
}
101 changes: 101 additions & 0 deletions endpoint/domain_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,3 +668,104 @@ func deserialize[T any](t *testing.T, serialized map[string]T) DomainFilter {

return deserialized
}

func TestDomainFilterMatchParent(t *testing.T) {
parentMatchTests := []domainFilterTest{
{
[]string{"a.example.com."},
[]string{},
[]string{"example.com"},
true,
map[string][]string{
"include": {"a.example.com"},
},
},
{
[]string{" a.example.com "},
[]string{},
[]string{"example.com"},
true,
map[string][]string{
"include": {"a.example.com"},
},
},
{
[]string{""},
[]string{},
[]string{"example.com"},
true,
map[string][]string{},
},
{
[]string{".a.example.com."},
[]string{},
[]string{"example.com"},
false,
map[string][]string{
"include": {".a.example.com"},
},
},
{
[]string{"a.example.com.", "b.example.com"},
[]string{},
[]string{"example.com"},
true,
map[string][]string{
"include": {"a.example.com", "b.example.com"},
},
},
{
[]string{"a.example.com"},
[]string{},
[]string{"b.example.com"},
false,
map[string][]string{
"include": {"a.example.com"},
},
},
{
[]string{"example.com"},
[]string{},
[]string{"example.com"},
false,
map[string][]string{
"include": {"example.com"},
},
},
{
[]string{"example.com"},
[]string{},
[]string{"anexample.com"},
false,
map[string][]string{
"include": {"example.com"},
},
},
{
[]string{""},
[]string{},
[]string{""},
true,
map[string][]string{},
},
}
for i, tt := range parentMatchTests {
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
domainFilter := NewDomainFilterWithExclusions(tt.domainFilter, tt.exclusions)

assertSerializes(t, domainFilter, tt.expectedSerialization)
deserialized := deserialize(t, map[string][]string{
"include": tt.domainFilter,
"exclude": tt.exclusions,
})

for _, domain := range tt.domains {
assert.Equal(t, tt.expected, domainFilter.MatchParent(domain), "%v", domain)
assert.Equal(t, tt.expected, domainFilter.MatchParent(domain+"."), "%v", domain+".")

assert.Equal(t, tt.expected, deserialized.MatchParent(domain), "deserialized %v", domain)
assert.Equal(t, tt.expected, deserialized.MatchParent(domain+"."), "deserialized %v", domain+".")
}
})
}
}
100 changes: 50 additions & 50 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,46 @@ go 1.21
require (
cloud.google.com/go/compute/metadata v0.2.3
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns v1.2.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.2.0
github.com/F5Networks/k8s-bigip-ctlr/v2 v2.15.0
github.com/F5Networks/k8s-bigip-ctlr/v2 v2.15.1
github.com/IBM-Cloud/ibm-cloud-cli-sdk v1.2.0
github.com/IBM/go-sdk-core/v5 v5.15.0
github.com/IBM/go-sdk-core/v5 v5.15.1
github.com/IBM/networking-go-sdk v0.44.0
github.com/akamai/AkamaiOPEN-edgegrid-golang v1.2.2
github.com/alecthomas/kingpin/v2 v2.4.0
github.com/aliyun/alibaba-cloud-sdk-go v1.62.652
github.com/aliyun/alibaba-cloud-sdk-go v1.62.673
github.com/ans-group/sdk-go v1.17.0
github.com/aws/aws-sdk-go v1.49.15
github.com/aws/aws-sdk-go v1.50.9
github.com/bodgit/tsig v1.2.2
github.com/cenkalti/backoff/v4 v4.2.1
github.com/civo/civogo v0.3.56
github.com/cloudflare/cloudflare-go v0.85.0
github.com/civo/civogo v0.3.58
github.com/cloudflare/cloudflare-go v0.87.0
github.com/cloudfoundry-community/go-cfclient v0.0.0-20190201205600-f136f9222381
github.com/datawire/ambassador v1.12.4
github.com/denverdino/aliyungo v0.0.0-20230411124812-ab98a9173ace
github.com/digitalocean/godo v1.107.0
github.com/digitalocean/godo v1.108.0
github.com/dnsimple/dnsimple-go v1.5.1
github.com/exoscale/egoscale v0.100.3
github.com/ffledgling/pdns-go v0.0.0-20180219074714-524e7daccd99
github.com/go-gandi/go-gandi v0.7.0
github.com/go-logr/logr v1.4.1
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.5.0
github.com/google/uuid v1.6.0
github.com/gophercloud/gophercloud v1.8.0
github.com/hooklift/gowsdl v0.5.0
github.com/infobloxopen/infoblox-go-client/v2 v2.4.0
github.com/infobloxopen/infoblox-go-client/v2 v2.5.0
github.com/linki/instrumented_http v0.3.0
github.com/linode/linodego v1.26.0
github.com/linode/linodego v1.28.0
github.com/maxatome/go-testdeep v1.14.0
github.com/miekg/dns v1.1.57
github.com/miekg/dns v1.1.58
github.com/nesv/go-dynect v0.6.0
github.com/nic-at/rc0go v1.1.1
github.com/onsi/ginkgo v1.16.5
github.com/openshift/api v0.0.0-20230607130528-611114dca681
github.com/openshift/client-go v0.0.0-20230607134213-3cd0021bbee3
github.com/oracle/oci-go-sdk/v65 v65.55.0
github.com/oracle/oci-go-sdk/v65 v65.57.0
github.com/ovh/go-ovh v1.4.3
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.9.1
Expand All @@ -54,37 +54,37 @@ require (
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.22
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.834
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.834
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/privatedns v1.0.834
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.856
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/dnspod v1.0.856
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/privatedns v1.0.856
github.com/transip/gotransip/v6 v6.23.0
github.com/ultradns/ultradns-sdk-go v1.3.7
github.com/vinyldns/go-vinyldns v0.9.16
github.com/vultr/govultr/v2 v2.17.2
go.etcd.io/etcd/api/v3 v3.5.11
go.etcd.io/etcd/client/v3 v3.5.11
go.etcd.io/etcd/api/v3 v3.5.12
go.etcd.io/etcd/client/v3 v3.5.12
go.uber.org/ratelimit v0.3.0
golang.org/x/net v0.19.0
golang.org/x/oauth2 v0.15.0
golang.org/x/net v0.20.0
golang.org/x/oauth2 v0.16.0
golang.org/x/sync v0.6.0
golang.org/x/time v0.5.0
google.golang.org/api v0.155.0
google.golang.org/api v0.161.0
gopkg.in/ns1/ns1-go.v2 v2.7.13
gopkg.in/yaml.v2 v2.4.0
istio.io/api v1.20.1
istio.io/client-go v1.20.1
k8s.io/api v0.29.0
k8s.io/apimachinery v0.29.0
k8s.io/client-go v0.29.0
k8s.io/klog/v2 v2.110.1
istio.io/api v1.20.2
istio.io/client-go v1.20.2
k8s.io/api v0.29.1
k8s.io/apimachinery v0.29.1
k8s.io/client-go v0.29.1
k8s.io/klog/v2 v2.120.1
sigs.k8s.io/gateway-api v1.0.0
)

require (
cloud.google.com/go/compute v1.23.3 // indirect
code.cloudfoundry.org/gofileutils v0.0.0-20170111115228-4d0c80011a0f // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 // indirect
github.com/Masterminds/semver v1.4.2 // indirect
github.com/Yamashou/gqlgenc v0.14.0 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
Expand All @@ -105,20 +105,20 @@ require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/errors v0.21.0 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/strfmt v0.21.7 // indirect
github.com/go-openapi/strfmt v0.22.0 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.15.5 // indirect
github.com/go-resty/resty/v2 v2.9.1 // indirect
github.com/go-playground/validator/v10 v10.17.0 // indirect
github.com/go-resty/resty/v2 v2.11.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
github.com/golang-jwt/jwt/v5 v5.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
Expand Down Expand Up @@ -146,7 +146,7 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/leodido/go-urn v1.3.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
Expand All @@ -164,7 +164,7 @@ require (
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/peterhellberg/link v1.1.0 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
Expand All @@ -188,29 +188,29 @@ require (
github.com/terra-farm/udnssdk v1.3.5 // indirect
github.com/vektah/gqlparser/v2 v2.5.1 // indirect
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.11 // indirect
go.mongodb.org/mongo-driver v1.12.1 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.12 // indirect
go.mongodb.org/mongo-driver v1.13.1 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 // indirect
go.opentelemetry.io/otel v1.22.0 // indirect
go.opentelemetry.io/otel/metric v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.22.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/tools v0.17.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231211222908-989df2bf70f3 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/grpc v1.60.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/go-playground/validator.v9 v9.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
Loading

0 comments on commit 9795c0b

Please sign in to comment.