Karta.Tracking.Traefik (Karta v1.0.0)

Traefik dynamic configuration for the tracking hosts in use (Karta.Tracking.Hosts) and the hosts of MTA-STS policies Karta serves (Karta.MTASTS.Hosting), the alternative to on-demand TLS for a reverse proxy that cannot ask: a file per host in a directory that Traefik's file provider watches, each a router from the host name to the service of Karta's tracking endpoint, with a certificate from a certificate resolver.

Configuration (config :karta, Karta.Tracking.Traefik, set from KARTA_TRACKING_TRAEFIK_*):

  • dir - the directory; without it no process runs;
  • service - the Traefik service that reaches the tracking endpoint, such as karta-tracking@docker;
  • cert_resolver - the routers' certificate resolver, such as letsencrypt; without one the routers use TLS with the certificates Traefik already has;
  • entry_points - the routers' entry points (by default all);
  • interval - milliseconds between two runs (default 60 seconds).

Each node writes its own directory when it starts and then every interval: a file karta-tracking-<host>.yml per host in use, written only when its content changed (under a temporary name first, then renamed, so Traefik never reads half a file), and the files of hosts no longer in use removed. Other files in the directory are left alone. When the database cannot be read or the directory cannot be written, the files stay as they are, a warning is logged, and the next run tries again.

Summary

Functions

Returns a specification to start this module under a supervisor.

The dynamic configuration of one host: a router named after it (dots as underscores, which host names cannot contain), for that host name only, to service, with TLS.

Starts the writer. Options: those of the configuration, and name.

Writes a file for each host in use (option hosts: these names instead) and removes the files of other hosts. Returns the names of the files written and removed.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

render(host, opts)

@spec render(String.t(), keyword()) :: String.t()

The dynamic configuration of one host: a router named after it (dots as underscores, which host names cannot contain), for that host name only, to service, with TLS.

start_link(opts)

Starts the writer. Options: those of the configuration, and name.

sync(opts)

@spec sync(keyword()) :: {:ok, %{written: [String.t()], removed: [String.t()]}}

Writes a file for each host in use (option hosts: these names instead) and removes the files of other hosts. Returns the names of the files written and removed.