-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add external-dns(v0.14.0) as a dependency
Adds external-dns (latest released version v0.14.0) as a go module dependency and updates the dnsrecord controller and dns provider logic to align with an external-dns approach to dns management. dnsrecord changes: * Replace v1alpha1.Endpoint with externaldns Endpoint * Add GetRootDomain to DNSRecord, returns the shortest domain that is shared across all spec.Endpoints dns names. provider changes: * Remove Ensure and Delete and instead include externaldnsprovider.Provider in provider.Provider interface. * Add provider.Config struct to hold common provider configuration, currently it only handles filters. Update provider Factory constructors accept the config as input. * Set DomainFilter, ZoneTypeFilter and ZoneIDFilter in provider implementations from provider.Config. provider aws changes: * Implement AdjustEndpoints to change our generic provider specific fields for weight and geo into aws ones understood by external-dns. provider google changes: * Copy external-dns google provider * Adds implementations of funtions required to translate endpoints and resourceRecordSets into the different states. - endpointsToProviderFormat - converts a list of endpoints into a google specific format. - endpointsFromResourceRecordSets - converts a list of `ResourceRecordSet` into endpoints (google format). - resourceRecordSetFromEndpoint - converts an endpoint(google format) into a `ResourceRecordSet`. controller changes: * Update DNSRecord controller to use applyChanges which follows an external-dns process to determine a set of changes(Create/Update/Delete) that are required to be made against the provider. * Use noop registry, no owner is currently set or checked for any records. * Setup provider filters: - DomainFilter = root domain for endpoints determined by calling dnsRecord.GetRootDomain() - ZoneTypeFilter = "", public or private zones considered. - ZoneIDFilter = set to single hosted zone id (managedZone.Status.ID) * Use sync policy, all changes will be applied (Create, Update and Deletes) * Use plan with above and using the current zone(plan.Current) and spec endpoints(plan.Desired) as input. additional changes: downgrade gatewayapiv1 to v0.7.1. This is required since the external dns aws provider is including the external dns source package which has a dependency on Gateway API v0.7.1. Downgrading is less than ideal, but dns-operator shouldn't have a dependency on gateway api, and the health check code that is currently causing it will likely be removed soon anyway in favour of provider health checks. There is also an opportunity to change external-dns to prevent it including the source package since it's including here for no reason other than getting a version https://github.com/kubernetes-sigs/external-dns/blob/master/provider/aws/session.go#L72
- Loading branch information
Showing
18 changed files
with
2,372 additions
and
912 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/external-dns/endpoint" | ||
) | ||
|
||
func TestDNSRecord_GetRootDomain(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
dnsNames []string | ||
want string | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "single endpoint", | ||
dnsNames: []string{ | ||
"test.example.com", | ||
}, | ||
want: "test.example.com", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "multiple endpoints matching", | ||
dnsNames: []string{ | ||
"bar.baz.test.example.com", | ||
"bar.test.example.com", | ||
"test.example.com", | ||
"foo.bar.baz.test.example.com", | ||
}, | ||
want: "test.example.com", | ||
wantErr: false, | ||
}, | ||
{ | ||
name: "no endpoints", | ||
dnsNames: []string{}, | ||
want: "", | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "multiple endpoints mismatching", | ||
dnsNames: []string{ | ||
"foo.bar.test.example.com", | ||
"bar.test.example.com", | ||
"baz.example.com", | ||
}, | ||
want: "", | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
s := &DNSRecord{ | ||
TypeMeta: metav1.TypeMeta{ | ||
Kind: "DNSRecord", | ||
APIVersion: GroupVersion.String(), | ||
}, | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "testRecord", | ||
Namespace: "testNS", | ||
}, | ||
Spec: DNSRecordSpec{ | ||
Endpoints: []*endpoint.Endpoint{}, | ||
}, | ||
} | ||
for idx := range tt.dnsNames { | ||
s.Spec.Endpoints = append(s.Spec.Endpoints, &endpoint.Endpoint{DNSName: tt.dnsNames[idx]}) | ||
} | ||
got, err := s.GetRootDomain() | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("GetRootDomain() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if got != tt.want { | ||
t.Errorf("GetRootDomain() got = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.