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

Support Traefik ingress controller #413

Closed
cknowles opened this issue Dec 5, 2017 · 19 comments
Closed

Support Traefik ingress controller #413

cknowles opened this issue Dec 5, 2017 · 19 comments
Labels
kind/support Categorizes issue or PR as a support question.

Comments

@cknowles
Copy link

cknowles commented Dec 5, 2017

I'd like to support Traefik as the ingress controller. Could someone point me in the right direction? I found the following code which seems to indicate Traefik would need to be updating the ingress status. Is there more to it than that?

https://github.com/kubernetes-incubator/external-dns/blob/b23765ed2722c5b39961eb6cf51d094c2db02d6b/source/ingress.go#L221

@hjacobs
Copy link
Contributor

hjacobs commented Dec 6, 2017

Yes, ideally the ingress controller updates the status field. There is a known workaround for ingress controllers who don't do that, see https://github.com/kubernetes-incubator/external-dns/blob/master/docs/faq.md#are-other-ingress-controllers-supported

@hjacobs hjacobs added the kind/support Categorizes issue or PR as a support question. label Dec 6, 2017
@cknowles
Copy link
Author

cknowles commented Dec 6, 2017

@hjacobs thanks, we've started using that annotation for now. I checked the status of our ingresses and it seems Traefik is not updating them so perhaps I should move this issue to the Traefik repo. I couldn't find much in the way of kube docs around updating the status of an Ingress.

@caarlos0
Copy link

caarlos0 commented Dec 7, 2017

@c-knowles did you manage to get this working?

@cknowles
Copy link
Author

cknowles commented Dec 8, 2017

@caarlos0 yeah, the instructions above work ok:

  1. Set metadata.annotations['external-dns.alpha.kubernetes.io/hostname'] on the Service record for the Ingress controller to something like ingress.YOUR-DOMAIN
  2. Wait for that to get actioned by external-dns so it creates the DNS record
  3. Set metadata.annotations['external-dns.alpha.kubernetes.io/target'] on the Ingress to ingress.YOUR-DOMAIN

The key to getting it to work on Route 53 at least was #2. From what I remember external-dns attempts to batch the DNS updates so if #1 is not in place first then the batch contains #1 and #3 which fails and it will never complete.

@rafaelmagu
Copy link

Any chance we can get these three steps added to the documentation as a side-note when using Traefik?

I'm using Helm to deploy Traefik and added this to my values.yaml:

service:
  annotations:
    external-dns.alpha.kubernetes.io/hostname: ingress.example.com

@coderanger
Copy link
Contributor

For others that find this, Traefik 1.7 now supports setting the required status fields. You'll have to set one of the [kubernetes.ingressEndpoint] settings in your config, such as:

[kubernetes.ingressEndpoint]
publishedService = "traefik/traefik"

See https://docs.traefik.io/v1.7/configuration/backends/kubernetes/#ingressendpoint for more details.

@dusansusic
Copy link

@coderanger i don't understand, does this mean that traefik 1.7 support external-dns? Thanks.

@coderanger
Copy link
Contributor

Yes, with that setting turned on Traefik 1.7 supports external-dns.

@dusansusic
Copy link

@coderanger thanks for fast answer.

what does this setting do?
publishedService = "traefik/traefik"

@coderanger
Copy link
Contributor

The ingress controller (traefik) needs to know what address to publish into DNS. You can either set a fixed IP or hostname, or set a service to copy the information from. The latter is the more common case, so that's setting the service to copy from to one named traefik in the namespace also named traefik. Or more generally you are specifying a service object in namespace/servicename format :)

@coderanger
Copy link
Contributor

Are you use you're using 1.7? You don't need to change it every time you make a new Ingress, as your example shows the status publish uses the Service (usually a LoadBalancer service) in front of the Traefik pods themselves. First check that the Service has a hostname or IP in its status:

$  kubectl get service -n traefik traefik -o=json | jq .status
{
  "loadBalancer": {
    "ingress": [
      {
        "ip": "35.230.xx.xx"
      }
    ]
  }
}

Then check that Traefik is correctly copying that to the status of the Ingress:

$  kubectl get ingress -n zomg zomg-web -o json | jq .status
{
  "loadBalancer": {
    "ingress": [
      {
        "ip": "35.230.xx.xx"
      }
    ]
  }
}

The thing external-dns actually cares about is that Status field in the Ingress (or Service if publishing those) so if it's set, you should be golden.

@bradenwright
Copy link

FYI for anyone using helm you just need to set the following:

kubernetes:
  ingressEndpoint:
    useDefaultPublishedService: true

https://github.com/helm/charts/blob/master/stable/traefik/values.yaml#L51

@bradenwright
Copy link

@c-knowles @hjacobs I'd consider this issue closed, I guess maybe worth updating documentation but its definitely supported and very easy to get working

@hjacobs
Copy link
Contributor

hjacobs commented Nov 6, 2018

@bradenwright let's have 1-2 sentences about it in the FAQ. I guess a new bullet item here makes sense: "Traefik is supported when setting the XYZ flag"

@coderanger
Copy link
Contributor

How about this:

@hjacobs
Copy link
Contributor

hjacobs commented Nov 6, 2018

PR welcome 😄

@cknowles
Copy link
Author

cknowles commented Nov 6, 2018

I can confirm this is working with the latest chart for Traefik and the above settings, we upgraded to that a couple of weeks ago and it's now setting the Ingress statuses which then gets picked up by external-dns automatically.

@mostrovoi
Copy link

How do you guys configure traefik to make this config work? I am not using helm so I created a configmap containing the following:
apiVersion: v1 kind: ConfigMap metadata: name: traefik-configmap namespace: ingress-sc data: traefik.toml: | [kubernetes] [kubernetes.ingressEndpoint] publishedService = "ingress-sc/traefik-ingress-service"
In the deployment section I set configfile pointing to the volume containing this configmap. I dont set --api neither --kubernetes as args since I read somewhere that if I set a configfile these will overwrite my configfile.
Could you guys provide a valid snippet to make this work?
Thanks!

@coderanger
Copy link
Contributor

@mostrovoi Explaining how to configure Traefik in general is out of scope for this ticket. Please ask on one of the various Slack channels or other support systems for Traefik.

lou-lan pushed a commit to lou-lan/external-dns that referenced this issue May 11, 2022
* pkg/index: ignore non-.yaml files during scanning

Turns out if there was a file in index/ directory with a non-.yaml extension,
we still targeted that as a plugin, so we tried to parse its manifest. (But
read/parsing of individual manifests do not cause fatal errors, just printed
to stderr like a warning.)

This creates a helper method that properly scans for .yaml files in an
immediate directory.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>

* rename variables

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Categorizes issue or PR as a support question.
Projects
None yet
Development

No branches or pull requests

8 participants