Create automatically all route for all container with the provider kubernetes-crd


I've a kubernetes cluster with a lot of containers. For this exemple, i've 20 containers "whoami" (port 80).

  • whoami1 (v1.0)
  • whoami2 (v1.1)
  • whoami3 (v1.2)

Each container are a differente version of whomai.

I've deployed traefik 2.6 with the provider kubernetes-crd and a whoami deployment (1 replicat) and i can traefik generate the good route for dahsboard and whami (i use service and ingressRoute). I've configured ingressRoute with kind Rule and match "Host(''). It's works fine.

But for other whoami container (20 or more), i want Traefik generate all the route automatically (the whomai containers are generate automatically every days with different count). How can i configued that without creating a service and ingressRoute for each containes ? For exemple i want the url " route to the container "whoami1" dynamically. And if i generate de container "whomai200", traefik generate a automatically route ""

With a docker provider i used this argument "--providers.docker.defaultRule=Host({{ normalize .Name }}". But how can i do the same with the provider kubenretes-crd.

Thanks !

Hello @erichardpollen

There is no such option available in Traefik Kubernetes CRD provider to dynamically create Ingress Resources and services based on the deployed pods (containers). I would try to use a combination of Kustomize and some shell scripting to create an ingress manifest and then deploy it on a Kubernetes cluster.

Ingressroute CRD requires to have Kubernetes service created that uses labels to match the pods. Then based on created Kubernetes endpoints Traefik will reach directly the pods. The service is only required during the discovery phase.

I am also thinking of introducing Flux to deploy the resources but still, the template using Kustomize should be prepared.

Thanks a lot for your reply !

To fix this problem, i created a dynamic Kubernetes script deployment with :

  • the deployment (pod)
  • the service
  • the ingressroute

Thank you !

This is very impressive, would you please share more details on how did you manage that? I am very interested in what the dynamic deployment script looks like. if you are willing to share more details about the final solution that would be super helpful for our community.
Thank you