Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Migrate Traefik Configuration To Environment Variables#813

Open
SamJUK wants to merge 1 commit intowardenenv:mainfrom
SamJUK:feature/migrate-traefik-config-to-env
Open

Migrate Traefik Configuration To Environment Variables#813
SamJUK wants to merge 1 commit intowardenenv:mainfrom
SamJUK:feature/migrate-traefik-config-to-env

Conversation

Copy link
Contributor

SamJUK commented Oct 20, 2024 *
edited
Loading

Currently overriding / extending the traefik.yml configuration is difficult. This PR proposes migrating the Traefik configuration from the .yml file to environment variables. This should improve both the extendability and maintainability of attempting to extend the Traefik config. Such as, but not limited to configuring plugins or certificate resolvers.

I've found there are 2 main pain points to the current approach.

  1. You have to overwrite and maintain the whole configuration file, even for a single value change.
  2. You have to edit the source file, since the svc up command replaces any modifications under $HOME/.warden/etc/traefik/traefik.yml See Here

Note: May be considered a breaking change. Since any custom changes to the traefik.yml by users would have to be reimplemented via the ENV approach. Due to Traefik static config approaches being mutually exclusive.


Example Use Case

Say you want to enable debug logging for Traefik. With the environment variable approach you can create a docker compose file in the warden home directory with the following contents.

# ~/.warden/docker-compose.yml
services:
traefik:
environment:
TRAEFIK_LOG_LEVEL: DEBUG

Or if you want to define a certificate resolver such as LetsEncrypt to sign your certs. It can again be defined in the users home directory with the following docker compose file. See this issue of someone attempting a similar thing and having to override the source file

# ~/.warden/docker-compose.yml
services:
traefik:
volumes:
- acmedata:/acme
environment:
CF_DNS_API_TOKEN: xxx
CF_ZONE_API_TOKEN: xxx
TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT: true
TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_ACME_EMAIL: admin@example.com
TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_ACME_STORAGE: /acme/acme.json
TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_ACME_CASERVER: https://acme-staging-v02.api.letsencrypt.org/directory
TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_ACME_DNSCHALLENGE: true
TRAEFIK_CERTIFICATESRESOLVERS_LETSENCRYPT_ACME_DNSCHALLENGE_PROVIDER: cloudflare
volumes:
acmedata:

SamJUK mentioned this pull request Oct 20, 2024
Copy link
Member

bap14 commented Oct 21, 2024

Thank you for the work on this @SamJUK !! I see no issues with this PR.

If we didn't want to wait until Warden 1.0 (or 0.15) to push this change we could add a Warden flag that is WARDEN_USE_TRAEFIK_ENV_CONFIG that if set to 1 then the config file is this new style, but if not set is the old way. Then also send a message to stderr which states that the Traefik static file config has been deprecated and will be removed in a future version and people should start switching to WARDEN_USE_TRAEFIK_ENV_CONFIG now.

Thoughts @navarr ?

bap14 approved these changes Oct 21, 2024
Copy link
Member

bap14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only improvement we could make is in the deprecation instead of immediate cessation of static config.

Copy link
Contributor

hardyjohnson commented Mar 21, 2025

I believe there is a happy path to an alternative with similar functionality which would not cause breaking change.

This could be achieved by creating a method which appends a partial from the home ~/.warden/config/traefik/traefik.yml during svc up, similar to how this is done for environments partials. This would follow the established pattern for extension and overriding without the need to break any existing setups.

If this suggestion is ignored and this PR moves forward so be it, but it should be a complete PR including the following:

  1. Parallel PR in the docs repo linked to this PR explaining the change for global service override for Traefik.
  2. Remove the existing config/traefik/traefik.yml file.
  3. Remove the copying of the traefik.yml file during svc up.
bap14 reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

bap14 bap14 approved these changes

Assignees

No one assigned

Labels

None yet

Projects

Status: No status

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants