From e9517f690fb41341b8797d5c3462ccae2194517b Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen.haas@lakedrops.com> Date: Thu, 30 Jun 2022 11:23:59 +0200 Subject: [PATCH] Update Traefik to 2.7 Add support for Traefik Hub --- Traefik.php | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/Traefik.php b/Traefik.php index bd8d8b3..8f5b607 100644 --- a/Traefik.php +++ b/Traefik.php @@ -49,6 +49,11 @@ class Traefik { */ protected $addon_portainer = FALSE; + /** + * @var string + */ + protected $hub_token = ''; + /** * Traefik constructor. * @@ -82,6 +87,13 @@ class Traefik { $this->addon_portainer = $addon_portainer; } + /** + * @param string $hub_token + */ + public function setHubToken(string $hub_token): void { + $this->hub_token = $hub_token; + } + /** * Update the Traefik container. */ @@ -135,7 +147,7 @@ class Traefik { 'version' => '3.3', 'services' => [ 'traefik' => [ - 'image' => 'traefik:2.6', + 'image' => 'traefik:2.7', 'command' => [ '--api=true', '--api.dashboard=true', @@ -202,6 +214,33 @@ class Traefik { ], ]; } + if ($this->hub_token) { + $config['services']['traefik']['command'][] = '--experimental.hub=true'; + $config['services']['traefik']['command'][] = '--hub.tls.insecure=true'; + $config['services']['traefik']['command'][] = '--metrics.prometheus.addrouterslabels=true'; + $config['services']['traefik']['ports'][] = '9900:9900'; + $config['services']['traefik']['ports'][] = '9901:9901'; + $config['services']['hub-agent'] = [ + 'image' => 'ghcr.io/traefik/hub-agent-traefik:v0.7.0', + 'command' => [ + 'run', + '--hub.token=' . $this->hub_token, + '--auth-server.advertise-url=http://hub-agent', + '--traefik.host=traefik', + '--traefik.tls.insecure=true', + ], + 'restart' => 'on-failure', + 'networks' => [ + 'traefik-public', + ], + 'volumes' => [ + '/var/run/docker.sock:/var/run/docker.sock:ro', + ], + 'depends_on' => [ + 'traefik', + ], + ]; + } return $config; } -- GitLab