ddns-updater icon indicating copy to clipboard operation
ddns-updater copied to clipboard

Feature request: Kubernetes API & external-dns as a provider

Open MOZGIII opened this issue 3 years ago • 6 comments

  1. What's the feature?

Teach ddns-updater to update the external-dns records in the Kubernetes API (via CRDs).

  1. Extra information?

To do. Just posting the idea here for now, will get back to it and fill it in if there are enough 👍 .

MOZGIII avatar Feb 02 '21 19:02 MOZGIII

Hi @MOZGIII, could you expand on this and explain the use case?

fredericrous avatar Feb 07 '21 19:02 fredericrous

I have a Kubernetes cluster at home that can manage the DNS via an external DNS provider. I'd like my cluster to also be in charge of updating the dynamic IP address through the same pipeline. There is a number of benefits to this: Kubernetes can be made aware of the IP address of its gateway, enabling some more advanced workflows.

Given it some thought, I am realizing that full-featured Kubernetes integration is probably not a good fit for this codebase - it has other concerns that should remain primary. However, it is possible to build a separate app to manage the Kubernetes state, that would accept simple HTTP requests from the ddns-updater, and take care of the external-dns state and other Kubernetes-related maintenance.

So, the initial flow I had in mind was ddns-updater (with direct support) -> kube-apiserver -> external-dns, but now I'm thinking about ddns-updater (as is) -> dynamic-dns-operator (a new thing) -> kube-apiserver -> external-dns.

MOZGIII avatar Feb 08 '21 10:02 MOZGIII

Is there an api endpoint that can be used to update the IP or do we have to generate a Kubernetes spec to do that? Looking at the doc, an endpoint might exist, but Kubernetes doc is a real labyrinth, I didn't find this info. If the solution relies on just calling an API, no need to create an external package. If the solution is to generate a spec, indeed creating a micro program, that communicates with ddns-updater, makes sense.

fredericrous avatar Feb 08 '21 13:02 fredericrous

Since this project uses Go, I don't think generating a spec is a way to talk to Kubernetes, but rather using its own client.

Take a look here for the CRD type: https://github.com/kubernetes-sigs/external-dns/blob/master/endpoint/endpoint.go We can also implement the connector source: https://github.com/kubernetes-sigs/external-dns/blob/master/source/connector.go

MOZGIII avatar Feb 08 '21 22:02 MOZGIII

taking inspiration on external-dns might be the optimal path indeed. But it might be simpler to use the go client instead. There is an example here https://github.com/kubernetes/client-go/blob/master/examples/in-cluster-client-configuration/main.go And there is a Open API spec: https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json The endpoint to set the IP seems to be io.k8s.api.core.v1.ServiceSpec

fredericrous avatar Feb 09 '21 17:02 fredericrous

I don't think you'd actually want to alter Services (I wouldn't in my use case). I'm using a custom CRD provided by the external-dns project - the one that actually manages the DNS records at the remote DNS provider. Service has some IPs we can set too, but they're not a good fit for these kinds of updates.

MOZGIII avatar Feb 09 '21 20:02 MOZGIII