ionos-cloud / external-dns-ionos-webhook

External-DNS Webhook to manage IONOS DNS Records
https://cloud.ionos.de
Apache License 2.0
17 stars 2 forks source link

Add IONOS cloud backend as DNS provider [DNS-790] #17

Closed akrieg-ionos closed 1 year ago

akrieg-ionos commented 1 year ago

Overview and Motivation

According the customer contract IONOS offers 2 public APIs for creating DNS entries:

The ionos plugin automatically uses the correct API based on the given IONOS_API_KEY.

This PR implements the support for the IONOS cloud DNS API.

mapping entities

External DNS uses the endpoint.Endpoint abstraction for a record in DNS. Normally, a DNS provider must map this abstraction to the entities of the DNS Provider API and vice versa. In this case for the IONOS cloud DNS API we have the entities from the ionos sdk-go-dns

Depedant from the use case there are wrapper of the core entities. Concrete you have to implement:

The interesting thing here is that these are not 1:1 relations. So, 2 RecordRead can be "merged" to 1 endpoint.Endpoint and vice versa. So the current criteria is when records have the same name, type and ttl they are mapped to one endpoint where the content of the record is a part of endpoint.Target []string.

handling zones

For finding and creating records you need a zone (id) as an input parameter. As there is no according abstraction on External DNS for zones, we need to derive the zone from the endpoint.Endpoint.DNSName. This is realized with a function for finding a zone for a domainName. The algorithm selects the zone which has the most equal domain parts with the given domain name. In order to minimize the api calls in the apply changes use case. We retrieve all zones from the customers at the beginning and the algorithm above operates on these zones which are in memory.

pagination and limits

The API offers pagination for retrieving zones and records on the customer level. We are using the max page size ( 1000) for the requests and limit the count of items to operate to 10000.

filtering

When retrieving zones and records through the API we only load the ones with the "Available" state. This filter is applied on the server side. Filtering names with the DomainFilter ( a feature coming from the External-DNS), is applied on the client side.