Previously I learned traefik by using docker compose to be a load balancer for my demo web application by using dynamic configuration and it works like a charm as the following configuration: -
At the moment, I've tried to learn the Traefik with Kubernetes by using Traefik Helm [1] and minikube. Everything also works like a charm until I try to make it to be a load balancer for my demo web application by using dynamic configuration.
At this point, I have no any clue how to add host mapping to /etc/hosts for Traefik Helm. Could you please help to advise?
I recommend you to have a look on the workshop I prepared entitled: Getting started with Traefik on Kubernetes. In the workshop I presented how to start with Traefik using the official Helm chart.
If you use Minikube and you would like to create a service type load balancer you need to start tunnel by executing command minikube tunnel and Traefik exposed ports will be binded to localhost belonging to your workstation.
Please note that in my workshop I use K3D - it is another alternative solution of deploying K8S cluster for learning purposes. Personally, I prefer that solution to deploy a cluster for testing / learning purposes.
Thank you very much for sharing the great and very intensive workshop video. Anyhow after finished watching, I cannot adapt to my current use case and situation as the following detail: -
The Traefik is deployed inside the kubernetes via Helm and it serves ping, metrics and dashboard perfectly.
On the other hand, my demo web application are not deployed inside the kubernetes. They reside at another machine with the plain old Tomcat and does not have any DNS.
I would like to make the Traefik to be a proxy/load balancer for them.
Inside the Traefik Pod. I'm able to use curl to make a connection to them via their IP address, but I would like to use the host name instead.
At the moment, I've no any clue how to append the host mapping to the /etc/hosts of the Traefik Pod as the same as I used to map with extra_hosts within the docker-compose.
If I correctly understood you, Traefik is deployed on Kubernetes and Tomcat is running as a standalne instance outside the cluster. You would like to use Traefik to act as load balancer for the Tomcat instance.
If so, you need to add to the Traefik's configuration FILE provider and create the configuration manually using Kubernetes ConfigMap.
In your file config you have to create router and service manually. You can of course follow our official docs to the File provider , routers and services that I highly encourage you to review. You can also use that example as a reference:
Thank you for quick reply. May I ask further about the url: http://10.11.0.2:8080 ? Am I able to use the host name rather than the IP address? Something like append the additional to the /etc/hosts inside the traefik pod ? Or the only way is having to use the IP address ? Could you please help to advise further?
Ahhh Yes . That's my question and my trying to achieve. How to make that URL to be reachable by the Traefik?
I have no any clue and hope that there is a way to edit the /etc/hosts via values.yaml. e.g. by using hostAliases [1]. But sadly, the Traefik _podtemplate.tpl [2] does not provide this to be happened and lead me to post this topic here.