Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to publish public WAN IP to DNS provider #1394

Closed
onedr0p opened this issue Jan 26, 2020 · 22 comments · Fixed by #2089
Closed

Option to publish public WAN IP to DNS provider #1394

onedr0p opened this issue Jan 26, 2020 · 22 comments · Fixed by #2089
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@onedr0p
Copy link
Contributor

onedr0p commented Jan 26, 2020

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.

@keslerm
Copy link

keslerm commented Feb 12, 2020

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.

@keslerm
Copy link

keslerm commented Feb 12, 2020

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

@onedr0p
Copy link
Contributor Author

onedr0p commented Feb 12, 2020

@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.

@keslerm
Copy link

keslerm commented Feb 12, 2020

@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.

@onedr0p
Copy link
Contributor Author

onedr0p commented Feb 12, 2020

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/

@keslerm
Copy link

keslerm commented Feb 12, 2020

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.

@Arno500
Copy link

Arno500 commented Feb 13, 2020

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.

@onedr0p
Copy link
Contributor Author

onedr0p commented Feb 17, 2020

@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?

@keslerm
Copy link

keslerm commented Feb 18, 2020

@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.

@fejta-bot
Copy link

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

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 18, 2020
@onedr0p
Copy link
Contributor Author

onedr0p commented May 18, 2020

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 18, 2020
@fejta-bot
Copy link

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

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 16, 2020
@onedr0p
Copy link
Contributor Author

onedr0p commented Aug 16, 2020

Bump!

@onedr0p
Copy link
Contributor Author

onedr0p commented Aug 16, 2020

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 16, 2020
@seanmalloy
Copy link
Member

/kind feature

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 17, 2020
@fejta-bot
Copy link

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

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 15, 2020
@onedr0p
Copy link
Contributor Author

onedr0p commented Nov 15, 2020

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 15, 2020
@jamesmoriarty
Copy link

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

@kferrone
Copy link

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?

@fejta-bot
Copy link

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-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 27, 2021
@fiskhest
Copy link

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 27, 2021
@bbl
Copy link
Contributor

bbl commented May 22, 2021

We had a similar requirement, so I created the following PR: #2089

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants