Skip to content

Commit ecd57c8

Browse files
authored
feat(ovh): major rewriting of the provider (#5143)
* feat: ovh: improve cache invalidation on errors + dry-run mode + relative CNAME handling + optimization Signed-off-by: Romain Beuque <[email protected]> * chore: add more tests Signed-off-by: Romain Beuque <[email protected]> * fix: align cache expiration with Default value * chore: address comments from review + updated documentation * chore: address comments from review --------- Signed-off-by: Romain Beuque <[email protected]>
1 parent 823ea7e commit ecd57c8

File tree

8 files changed

+704
-258
lines changed

8 files changed

+704
-258
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ExternalDNS allows you to keep selected zones (via `--domain-filter`) synchroniz
5757
- [RFC2136](https://tools.ietf.org/html/rfc2136)
5858
- [NS1](https://ns1.com/)
5959
- [TransIP](https://www.transip.eu/domain-name/)
60-
- [OVH](https://www.ovh.com)
60+
- [OVHcloud](https://www.ovhcloud.com)
6161
- [Scaleway](https://www.scaleway.com)
6262
- [Akamai Edge DNS](https://learn.akamai.com/en-us/products/cloud_security/edge_dns.html)
6363
- [GoDaddy](https://www.godaddy.com)
@@ -85,7 +85,7 @@ See PR #3063 for all the discussions about it.
8585
Known providers using webhooks:
8686

8787
| Provider | Repo |
88-
|-----------------------|----------------------------------------------------------------------|
88+
| --------------------- | -------------------------------------------------------------------- |
8989
| Abion | https://github.com/abiondevelopment/external-dns-webhook-abion |
9090
| Adguard Home Provider | https://github.com/muhlba91/external-dns-provider-adguard |
9191
| Anexia | https://github.com/ProbstenHias/external-dns-anexia-webhook |
@@ -145,7 +145,7 @@ The following table clarifies the current status of the providers according to t
145145
| RFC2136 | Alpha | |
146146
| NS1 | Alpha | |
147147
| TransIP | Alpha | |
148-
| OVH | Alpha | |
148+
| OVHcloud | Beta | @rbeuque74 |
149149
| Scaleway DNS | Alpha | @Sh4d1 |
150150
| UltraDNS | Alpha | |
151151
| GoDaddy | Alpha | |
@@ -207,7 +207,7 @@ The following tutorials are provided:
207207
- [PowerDNS](docs/tutorials/pdns.md)
208208
- [RFC2136](docs/tutorials/rfc2136.md)
209209
- [TransIP](docs/tutorials/transip.md)
210-
- [OVH](docs/tutorials/ovh.md)
210+
- [OVHcloud](docs/tutorials/ovh.md)
211211
- [Scaleway](docs/tutorials/scaleway.md)
212212
- [UltraDNS](docs/tutorials/ultradns.md)
213213
- [GoDaddy](docs/tutorials/godaddy.md)

docs/flags.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
| `--inmemory-zone=` | Provide a list of pre-configured zones for the inmemory provider; specify multiple times for multiple zones (optional) |
108108
| `--ovh-endpoint="ovh-eu"` | When using the OVH provider, specify the endpoint (default: ovh-eu) |
109109
| `--ovh-api-rate-limit=20` | When using the OVH provider, specify the API request rate limit, X operations by seconds (default: 20) |
110+
| `--[no-]ovh-enable-cname-relative` | When using the OVH provider, specify if CNAME should be treated as relative on target without final dot (default: false) |
110111
| `--pdns-server="http://localhost:8081"` | When using the PowerDNS/PDNS provider, specify the URL to the pdns server (required when --provider=pdns) |
111112
| `--pdns-server-id="localhost"` | When using the PowerDNS/PDNS provider, specify the id of the server to retrieve. Should be `localhost` except when the server is behind a proxy (optional when --provider=pdns) (default: localhost) |
112113
| `--pdns-api-key=""` | When using the PowerDNS/PDNS provider, specify the API key to use to authorize requests (required when --provider=pdns) |

docs/tutorials/ovh.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
# OVHcloud
22

33
This tutorial describes how to setup ExternalDNS for use within a
4-
Kubernetes cluster using OVH DNS.
4+
Kubernetes cluster using OVHcloud DNS.
55

66
Make sure to use **>=0.6** version of ExternalDNS for this tutorial.
77

8-
## Creating a zone with OVH DNS
8+
## Creating a zone with OVHcloud DNS
99

10-
If you are new to OVH, we recommend you first read the following
10+
If you are new to OVHcloud, we recommend you first read the following
1111
instructions for creating a zone.
1212

13-
[Creating a zone using the OVH manager](https://docs.ovh.com/gb/en/domains/create_a_dns_zone_for_a_domain_which_is_not_registered_at_ovh/)
13+
[Creating a zone using the OVHcloud Manager](https://help.ovhcloud.com/csm/en-gb-dns-create-dns-zone?id=kb_article_view&sysparm_article=KB0051667/)
1414

15-
[Creating a zone using the OVH API](https://api.ovh.com/console/)
15+
[Creating a zone using the OVHcloud API](https://api.ovh.com/console/)
1616

17-
## Creating OVH Credentials
17+
## Creating OVHcloud Credentials
1818

19-
You first need to create an OVH application.
20-
21-
Using the [OVH documentation](https://docs.ovh.com/gb/en/api/first-steps-with-ovh-api/#advanced-usage-pair-ovhcloud-apis-with-an-application_2) you will have your `Application key` and `Application secret`
19+
You first need to create an OVHcloud application: follow the
20+
[OVHcloud documentation](https://help.ovhcloud.com/csm/en-gb-api-getting-started-ovhcloud-api?id=kb_article_view&sysparm_article=KB0042784#advanced-usage-pair-ovhcloud-apis-with-an-application)
21+
you will have your `Application key` and `Application secret`
2222

2323
And you will need to generate your consumer key, here the permissions needed :
2424

2525
- GET on `/domain/zone`
2626
- GET on `/domain/zone/*/record`
2727
- GET on `/domain/zone/*/record/*`
28+
- PUT on `/domain/zone/*/record/*`
2829
- POST on `/domain/zone/*/record`
2930
- DELETE on `/domain/zone/*/record/*`
3031
- GET on `/domain/zone/*/soa`
@@ -51,6 +52,10 @@ curl -XPOST -H "X-Ovh-Application: <ApplicationKey>" -H "Content-type: applicati
5152
"method": "GET",
5253
"path": "/domain/zone/*/record/*"
5354
},
55+
{
56+
"method": "PUT",
57+
"path": "/domain/zone/*/record/*"
58+
},
5459
{
5560
"method": "POST",
5661
"path": "/domain/zone/*/record"
@@ -223,7 +228,7 @@ spec:
223228
224229
**A note about annotations**
225230
226-
Verify that the annotation on the service uses the same hostname as the OVH DNS zone created above. The annotation may also be a subdomain of the DNS zone (e.g. 'www.example.com').
231+
Verify that the annotation on the service uses the same hostname as the OVHcloud DNS zone created above. The annotation may also be a subdomain of the DNS zone (e.g. 'www.example.com').
227232
228233
The TTL annotation can be used to configure the TTL on DNS records managed by ExternalDNS and is optional. If this annotation is not set, the TTL on records managed by ExternalDNS will default to 10.
229234
@@ -235,11 +240,11 @@ ExternalDNS uses the hostname annotation to determine which services should be r
235240
kubectl create -f nginx.yaml
236241
```
237242

238-
Depending on where you run your service, it may take some time for your cloud provider to create an external IP for the service. Once an external IP is assigned, ExternalDNS detects the new service IP address and synchronizes the OVH DNS records.
243+
Depending on where you run your service, it may take some time for your cloud provider to create an external IP for the service. Once an external IP is assigned, ExternalDNS detects the new service IP address and synchronizes the OVHcloud DNS records.
239244

240-
## Verifying OVH DNS records
245+
## Verifying OVHcloud DNS records
241246

242-
Use the OVH manager or API to verify that the A record for your domain shows the external IP address of the services.
247+
Use the OVHcloud manager or API to verify that the A record for your domain shows the external IP address of the services.
243248

244249
## Cleanup
245250

internal/gen/docs/flags/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (f *Flags) addFlag(name, description string) {
4646

4747
// It generates a markdown file
4848
// with the supported flags and writes it to the 'docs/flags.md' file.
49-
// to re-generate `docs/flags.md` execute 'go run internal/gen/main.go'
49+
// to re-generate `docs/flags.md` execute 'go run internal/gen/docs/flags/main.go'
5050
func main() {
5151
testPath, _ := os.Getwd()
5252
path := fmt.Sprintf("%s/docs/flags.md", testPath)

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func main() {
267267
case "digitalocean":
268268
p, err = digitalocean.NewDigitalOceanProvider(ctx, domainFilter, cfg.DryRun, cfg.DigitalOceanAPIPageSize)
269269
case "ovh":
270-
p, err = ovh.NewOVHProvider(ctx, domainFilter, cfg.OVHEndpoint, cfg.OVHApiRateLimit, cfg.DryRun)
270+
p, err = ovh.NewOVHProvider(ctx, domainFilter, cfg.OVHEndpoint, cfg.OVHApiRateLimit, cfg.OVHEnableCNAMERelative, cfg.DryRun)
271271
case "linode":
272272
p, err = linode.NewLinodeProvider(domainFilter, cfg.DryRun, externaldns.Version)
273273
case "dnsimple":

pkg/apis/externaldns/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ type Config struct {
131131
InMemoryZones []string
132132
OVHEndpoint string
133133
OVHApiRateLimit int
134+
OVHEnableCNAMERelative bool
134135
PDNSServer string
135136
PDNSServerID string
136137
PDNSAPIKey string `secure:"yes"`
@@ -295,6 +296,7 @@ var defaultConfig = &Config{
295296
InMemoryZones: []string{},
296297
OVHEndpoint: "ovh-eu",
297298
OVHApiRateLimit: 20,
299+
OVHEnableCNAMERelative: false,
298300
PDNSServer: "http://localhost:8081",
299301
PDNSServerID: "localhost",
300302
PDNSAPIKey: "",
@@ -544,6 +546,7 @@ func App(cfg *Config) *kingpin.Application {
544546
app.Flag("inmemory-zone", "Provide a list of pre-configured zones for the inmemory provider; specify multiple times for multiple zones (optional)").Default("").StringsVar(&cfg.InMemoryZones)
545547
app.Flag("ovh-endpoint", "When using the OVH provider, specify the endpoint (default: ovh-eu)").Default(defaultConfig.OVHEndpoint).StringVar(&cfg.OVHEndpoint)
546548
app.Flag("ovh-api-rate-limit", "When using the OVH provider, specify the API request rate limit, X operations by seconds (default: 20)").Default(strconv.Itoa(defaultConfig.OVHApiRateLimit)).IntVar(&cfg.OVHApiRateLimit)
549+
app.Flag("ovh-enable-cname-relative", "When using the OVH provider, specify if CNAME should be treated as relative on target without final dot (default: false)").Default(strconv.FormatBool(defaultConfig.OVHEnableCNAMERelative)).BoolVar(&cfg.OVHEnableCNAMERelative)
547550
app.Flag("pdns-server", "When using the PowerDNS/PDNS provider, specify the URL to the pdns server (required when --provider=pdns)").Default(defaultConfig.PDNSServer).StringVar(&cfg.PDNSServer)
548551
app.Flag("pdns-server-id", "When using the PowerDNS/PDNS provider, specify the id of the server to retrieve. Should be `localhost` except when the server is behind a proxy (optional when --provider=pdns) (default: localhost)").Default(defaultConfig.PDNSServerID).StringVar(&cfg.PDNSServerID)
549552
app.Flag("pdns-api-key", "When using the PowerDNS/PDNS provider, specify the API key to use to authorize requests (required when --provider=pdns)").Default(defaultConfig.PDNSAPIKey).StringVar(&cfg.PDNSAPIKey)

0 commit comments

Comments
 (0)