Closed kadaan closed 2 years ago
@tiredofit Feedback?
Very nice stuff, I'm always in awe at others programming skills vs my "hacks". My only suggestion here is to be a bit more explicit with the environment variables TRAEFIK_MODE
and TRAEFIK_URL
. Suggest that they stay as close as possible to the method of what is being done here ie ENABLE_TRAEFIK_POLL=TRUE
and TRAEFIK_POLL_URL
and then we'll just need to be clear in the README
on its usage and that its for specific purposes. How does that sound?
@tiredofit Added documentation and did the renames suggested. Also gated the traefik polling on TRAEFIK_VERSION=2
@tiredofit One change to think about is that before we would always add/update CloudFlare, but now we only do it if the host is not in our bookkeeping. This means that if you delete the CNAME in CloudFlare we will not add it back unless cloudflare-companion is restart. This was possible before because you listed to events to know what to do. Now, with polling, we don't have the luxury of only getting a stream of change and we don't want to update CloudFlare every 60s.
Many thanks for this contribution.
Tagged and released as 6.8.0
This is a first stab at adding support for external services. This is done by adding an optional Traefik poll loop which looks for HTTP routers that are not using the Socker provider. If they have a Host rule, it will be extracted and similar logic to
check_container_t2
will be performed.Discovery of routes and update of cloudflare now happen in two different phases. First we discover all routes. Then we take this route list and compare to the list of already synced routes, anything new is pushed to cloudflare. If the route is pushed to cloudflare successfully, we record that route in our synced routes. Docker routes are given priority.
For the initial load we load all docker routes and non-docker routes. We start a recurrent task that will inspect Traefik for new routes. We also start the docker event stream monitor.
To enable polling of Traefik for routes you need to:
TRAEFIK_MODE=TRUE
environment variableTRAEFIK_URL=http://xxx.xxx.xxx.xxx:8080
environment variableOptionally:
TRAEFIK_POLL_SECONDS
to increase or decrease the frequency of inspecting Traefik. The 60s default seems decentTRAEFIK_INCLUDED_HOST1
...TRAEFIK_INCLUDED_HOST<N>
. The.*
default include all non-docker routesTRAEFIK_EXCLUDED_HOST1
...TRAEFIK_EXCLUDED_HOST<N>
NOTE: The exclude filters override the include filters.
The DRY_RUN environment variable has been added. When set to
TRUE
it will run through all the normal logic, but not actually perform the cloudflare updates.The scheduling service on the container has also been disabled, it was not needed.