Kuadrant / Kuadrant/dns-operator

Update providers (non AWS) from external-dns

Open
#743 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
12
Forks
23
Avg merge
1d 4h
Merged PRs (30d)
14

Description

The AWS is here [#742](https://github.com/Kuadrant/dns-operator/issues/742)

## Why
Separate from AWS as it moved to a new SDK version. The rest of the providers did not change much in `external-dns`. And we also changed them minimally.

## What
Take the `external-dns` code and update dependencies. Then apply our changes:

GCP:
1. Add a `logger` (`logr.Logger`) to the `GoogleProvider` struct, add context to the constructor (to init logger with context) and replace the old logger with the new one.
2. Make the [constructor](https://github.com/kubernetes-sigs/external-dns/blob/master/provider/google/google.go#L128) consume the [config](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/google/google.go#L140) (or ditch the config struct and pass params directly)
3. Split [NewGoogleProvider()](https://github.com/kubernetes-sigs/external-dns/blob/master/provider/google/google.go#L128) into [NewGoogleProvider()](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/google/google.go#L140) and [NewGoogleProviderWithService()](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/google/google.go#L154)
4. Get rid of the [instrumented client](https://github.com/kubernetes-sigs/external-dns/blob/master/provider/google/google.go#L134) we have it in the [caller](https://github.com/Kuadrant/dns-operator/blob/main/internal/provider/google/google.go#L141)
5. Add [resourceREcordSetFromEndpoint()](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/google/google.go#L472-L560) - needed for geo/weighted stuff that `external-dns` is [missing](https://github.com/kubernetes-sigs/external-dns/blob/master/provider/google/google.go#L421-L461)
6. The `SoftError` type. We will need to adjust accordingly.

Azure:
1. Same logger stuff as above
2. Export a bunch of stuff: `AzureChangeMap`, `MapChanges()`, `RecordSetNameForZone()`, `NewRecordSet()` and so on
3. Add [NewAzureProviderFromConfig(ctx, Config)](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/azure/azure.go#L71-L106) - the `external-dns` seems to have it [joined](https://github.com/kubernetes-sigs/external-dns/blob/master/provider/azure/azure.go#L74-L106).
4. Add TrafficManager [client](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/azure/azure.go#L65-L67) fields (will need to add [this](https://github.com/kubernetes-sigs/external-dns/blob/master/provider/azure/azure.go#L93-L105) factory).
5. Add [CleanAzureError()](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/azure/azure.go#L495-L509)
6. Add [provider.EnsureTrailingDot(target)](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/azure/azure.go#L402-L405) for NS record targets
7. The same `SoftError` decision as above.
8. We use [yaml.Unmarshal()](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/azure/config.go#L62) for error
9. We have [more](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/azure/config.go#L49-L53) stuff in the config instead of [passing](https://github.com/kubernetes-sigs/external-dns/blob/master/provider/azure/azure.go#L74) them one by one to the constructor. Also simplyfies the `getConfig()` signature
10. Use [transporter](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/azure/config.go#L89-L91) from [here](https://github.com/Kuadrant/dns-operator/blob/main/internal/provider/azure/azure.go#L70).
11. The `external-dns` [added](https://github.com/kubernetes-sigs/external-dns/blob/master/provider/azure/config.go#L198-L218) ResourceManagerAudience, ResourceManagerEndpoint for AzureStack to [getCouldConfig()](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/azure/config.go#L159-L169) - decide whether to keep.

Inmemory:
1. The same logger stuff
2. Export stuff (like `InMemoryClient`)
3. Add to InMemoryClient struct. [Add](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/inmemory/inmemory.go#L297-L373) RLock/RUnlock to read methods, Lock/Unlock to write methods
4. Add [DeleteZonne()](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/inmemory/inmemory.go#L335-L344), [GetZone()](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/inmemory/inmemory.go#L346-L354) and [InMemoryWithClient()](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/inmemory/inmemory.go#L110-L116)
5. Add TXT [validation](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/inmemory/inmemory.go#L436-L466)
6. Replace [im.filter.Zones() ](https://github.com/kubernetes-sigs/external-dns/blob/master/provider/inmemory/inmemory.go#L120-L123) with [im.domain.Match() ](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/inmemory/inmemory.go#L152-L164) or update their [filter](https://github.com/kubernetes-sigs/external-dns/blob/master/provider/inmemory/inmemory.go#L215-L228)
7. Change [domainFilter](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/inmemory/inmemory.go#L62) to [interface](https://github.com/kubernetes-sigs/external-dns/blob/master/provider/inmemory/inmemory.go#L50) version. They seemed to move to interface, but I can't see how that affects us.
8. Use deep equal for targets in [validateChangeBatch](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/inmemory/inmemory.go#L420-L428)
9. [Ignore](https://github.com/Kuadrant/dns-operator/blob/main/internal/external-dns/provider/inmemory/inmemory.go#L103) the "alreadyExists" error in [InMemoryInitZones()](https://github.com/kubernetes-sigs/external-dns/blob/master/provider/inmemory/inmemory.go#L88)

Contributor guide

Open the contributing guide

Research direction

Compare the provider implementations under internal/external-dns/provider/google, azure, and inmemory with the corresponding external-dns versions. Start with each provider's constructors, configuration, clients, and listed helper methods, then inspect their callers under internal/provider. Done means the non-AWS providers are updated while preserving the project-specific logger, configuration, provider behavior, and concurrency changes described here.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, cloud
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.