Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support cnames and aaaa for default-targets #3745

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/apis/externaldns/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ func (cfg *Config) ParseFlags(args []string) error {
app.Flag("crd-source-kind", "Kind of the CRD for the crd source in API group and version specified by crd-source-apiversion").Default(defaultConfig.CRDSourceKind).StringVar(&cfg.CRDSourceKind)
app.Flag("service-type-filter", "The service types to take care about (default: all, expected: ClusterIP, NodePort, LoadBalancer or ExternalName)").StringsVar(&cfg.ServiceTypeFilter)
app.Flag("managed-record-types", "Record types to manage; specify multiple times to include many; (default: A, AAAA, CNAME) (supported records: CNAME, A, AAAA, NS").Default("A", "AAAA", "CNAME").StringsVar(&cfg.ManagedDNSRecordTypes)
app.Flag("default-targets", "Set globally default IP address that will apply as a target instead of source addresses. Specify multiple times for multiple targets (optional)").StringsVar(&cfg.DefaultTargets)
app.Flag("default-targets", "Set globally default host/IP that will apply as a target instead of source addresses. Specify multiple times for multiple targets (optional)").StringsVar(&cfg.DefaultTargets)
app.Flag("target-net-filter", "Limit possible targets by a net filter; specify multiple times for multiple possible nets (optional)").StringsVar(&cfg.TargetNetFilter)
app.Flag("exclude-target-net", "Exclude target nets (optional)").StringsVar(&cfg.ExcludeTargetNets)

Expand Down
6 changes: 4 additions & 2 deletions source/multisource.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ func (ms *multiSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, err
}
if len(ms.defaultTargets) > 0 {
for i := range endpoints {
endpoints[i].Targets = ms.defaultTargets
eps := endpointsForHostname(endpoints[i].DNSName, ms.defaultTargets, endpoints[i].RecordTTL, endpoints[i].ProviderSpecific, endpoints[i].SetIdentifier)
cgroschupp marked this conversation as resolved.
Show resolved Hide resolved
result = append(result, eps...)
}
} else {
result = append(result, endpoints...)
}
result = append(result, endpoints...)
}

return result, nil
Expand Down
10 changes: 7 additions & 3 deletions source/multisource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,16 @@ func testMultiSourceEndpointsWithError(t *testing.T) {

func testMultiSourceEndpointsDefaultTargets(t *testing.T) {
// Create the expected default targets
defaultTargets := []string{"127.0.0.1", "127.0.0.2"}
defaultTargetsA := []string{"127.0.0.1", "127.0.0.2"}
defaultTargetsCName := []string{"foo.example.org"}
defaultTargets := append(defaultTargetsA, defaultTargetsCName...)

// Create the expected endpoints
expectedEndpoints := []*endpoint.Endpoint{
{DNSName: "foo", Targets: defaultTargets},
{DNSName: "bar", Targets: defaultTargets},
{DNSName: "foo", Targets: defaultTargetsA, RecordType: "A"},
{DNSName: "bar", Targets: defaultTargetsA, RecordType: "A"},
{DNSName: "foo", Targets: defaultTargetsCName, RecordType: "CNAME"},
{DNSName: "bar", Targets: defaultTargetsCName, RecordType: "CNAME"},
cgroschupp marked this conversation as resolved.
Show resolved Hide resolved
}

// Create the source endpoints with different targets
Expand Down