Bring up traefik on host 0.0.0.0

Ideally, when I bring up a simple http server using python -m http.server 8081, it runs on 0.0.0.0:8081 which can be connected from a different pod. Upon giving the netstat -nlp command, I see that the local address is 0.0.0.0:8081 and the foreign address is 0.0.0.0:* which indicates that this service is running on all ip addresses and I am able to connect to it from a different pod.

Similarly, I would like Traefik service to run on one kubernetes pod and connect to it from a different pod. I used the below config file to bring traefik up on all ip addresses.

[api]
dashboard = 'true'

[entryPoints]
[entryPoints.http]
address = "0.0.0.0:8080"

[entryPoints.auth_api]
address = "0.0.0.0:8081"

[providers.redis]
endpoints = [ "redis:6379"]
rootKey = "traefik"

I used 0.0.0.0:8081 so that, traefik can be discovered from another pod in the same host network. Upon netstat -nlp, I see that the local address is :::8080 and the foreign address is :::*, which makes me wonder if the service is not discoverable from a different pod. When I try to connect to the traefik from a different pod using the below code, it throws me HTTP 404 error.

from tornado.httpclient import AsyncHTTPClient
resp = await AsyncHTTPClient().fetch('http://0.0.0.0:8081/api/overview', auth_username='api_admin', auth_password='admin')

From the same traefik pod, if I use the below, it is successful,

from tornado.httpclient import AsyncHTTPClient
resp = await AsyncHTTPClient().fetch('http://localhost:8081/api/overview', auth_username='api_admin', auth_password='admin')

From the same traefik pod, if I use the below, it is HTTP 404 again,

from tornado.httpclient import AsyncHTTPClient
resp = await AsyncHTTPClient().fetch('http://0.0.0.0:8081/api/overview', auth_username='api_admin', auth_password='admin')

Not sure why the traefik cannot be discovered on 0.0.0.0:8081. I would totally appreciate any help here. Thanks traefik community!

If this is k8s related, then I recommend use appropriate tags for your post.

1 Like