External-dns: Option to publish public WAN IP to DNS provider

Created on 26 Jan 2020  路  19Comments  路  Source: kubernetes-sigs/external-dns

I am running a Kubernetes cluster from my house and I don't have a static IP. After deploying exteral-dns I found out that it is sending my Load Balancer IP (192.168.x.x) to my DNS providers A record. This is pointless for my use-case. It would be cool if this service could look up my public WAN IP and use that instead.

For example I am using this Docker image to do this, but I am missing out on all the neat features external-dns provides.

kinfeature

Most helpful comment

Actually just pieced it together, there is already an annotation you can use

external-dns.alpha.kubernetes.io/target: x.x.x.x

https://github.com/kubernetes-sigs/external-dns/blob/master/docs/faq.md#are-other-ingress-controllers-supported

@onedr0p what i'm doing is using an external service to provide ddns for a single A record, then setting the target to that A record which creates a CNAME
Example annotations:

    external-dns.alpha.kubernetes.io/hostname: test.example.com
    external-dns.alpha.kubernetes.io/target: cname.example.com

All 19 comments

Just went to see if this is possible, would be really nice to have this ability. We are using bare metal k8s clusters and can't use external-dns for this, even just an annotation that we could specify the IP To use somewhere.

Actually just pieced it together, there is already an annotation you can use

external-dns.alpha.kubernetes.io/target: x.x.x.x

https://github.com/kubernetes-sigs/external-dns/blob/master/docs/faq.md#are-other-ingress-controllers-supported

@onedr0p what i'm doing is using an external service to provide ddns for a single A record, then setting the target to that A record which creates a CNAME
Example annotations:

    external-dns.alpha.kubernetes.io/hostname: test.example.com
    external-dns.alpha.kubernetes.io/target: cname.example.com

@keslerm that's great! However, since I don't have a static IP address it's more of an issue to have my home IP address automatically pushed to an external DNS provider.

@onedr0p yeah i don't have a static ip either, i use my router to do dynamic dns to the single a record cname.example.com so I can just point everything else to that cname and it'll always be up to date without me hard coding ip's in the ingress/service definitions.

Interesting, I am using a USG 4 Pro and I don't have my provider (CloudFlare) listed there :/ heh maybe one day.

image

Edit, there appears to be a hacky way to do this with the USG but I am not sure about doing it :)

https://christian-gmeiner.info/2019-07-13-cloudflare-ddns-usg/

You've already got kubernetes running, can always just deploy a software solution that does the same thing - don't have to use the router.

I'm stuck on bare metal with the same problem. My Nginx Ingress can only publish internal IPs to ingresses and external-dns is blindly catching them. But they go nowhere outside the local network.
It would be awesome if it was possible to set IPs in the DeploymentSet or DaemonSet via annotations.
Or directly on the external-dns pod to allow for a global override.

@keslerm I am a little lost between the target and hostname annotations. In your setup, do you have external-dns updating and creating cname records on a provider for you based on ingress?

@onedr0p i have my router updating the record cname.example.com in cloudflare with it's dynamic dns updater service (it's pfsense). I manually set this up outside of external dns.

Then in all the ingresses I set the target as the cname. external-dns sets the record for test.example.com to point to cname cname.example.com

This way all the hostnames for my ingresses will resolve to the single cname that the dynamic dns script keeps up to date, i don't have to hard code any IP addresses. If my IP ever changes, the cname will be updated to my new ip and the other records will automatically follow suit without external-dns needing to do anything.

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

/remove-lifecycle stale

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

Bump!

/remove-lifecycle stale

/kind feature

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

/remove-lifecycle stale

Update: /target didn't work for Service but did with Ingress.

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: ip
spec:
  schedule: "*/30 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: ip
            image: bitnami/kubectl
            command:
            - /bin/sh
            - -c
            - |
              cat << EOF > /tmp/ingress.yml && kubectl apply -f /tmp/ingress.yml
              apiVersion: networking.k8s.io/v1
              kind: Ingress
              metadata:
                name: ip
                annotations:
                  kubernetes.io/ingress.class: nginx
                  external-dns.alpha.kubernetes.io/hostname: '$IP_HOSTNAME'
                  external-dns.alpha.kubernetes.io/target: '$(curl --silent ifconfig.me)'
              spec:
                rules:
                - host: '$IP_HOSTNAME'
              EOF
            env:
            - name: IP_HOSTNAME
              value: ip.home.jamesmoriarty.xyz
          restartPolicy: OnFailure

Appears to work:

dig ANY ip.home.jamesmoriarty.xyz
...
ip.home.jamesmoriarty.xyz. 299  IN      A       110.144.147.83

Yeah bump this one. Been trying to get clever to no avail. Shouldn't be too hard for External DNS to discover the WAN IP right?

Was this page helpful?
0 / 5 - 0 ratings