diff --git a/cmd/traefik/traefik.go b/cmd/traefik/traefik.go index d4674b14d7..0a772de1e3 100644 --- a/cmd/traefik/traefik.go +++ b/cmd/traefik/traefik.go @@ -222,6 +222,10 @@ func setupServer(staticConfiguration *static.Configuration) (*server.Server, err }) } + if staticConfiguration.Pilot != nil { + version.PilotEnabled = staticConfiguration.Pilot.Dashboard + } + // Plugins pluginBuilder, err := createPluginBuilder(staticConfiguration) diff --git a/docs/content/reference/static-configuration/cli-ref.md b/docs/content/reference/static-configuration/cli-ref.md index 934569ab37..b612b2693e 100644 --- a/docs/content/reference/static-configuration/cli-ref.md +++ b/docs/content/reference/static-configuration/cli-ref.md @@ -294,6 +294,9 @@ Prefix to use for metrics collection. (Default: ```traefik```) `--metrics.statsd.pushinterval`: StatsD push interval. (Default: ```10```) +`--pilot.dashboard`: +Enable Traefik Pilot in the dashboard. (Default: ```true```) + `--pilot.token`: Traefik Pilot token. diff --git a/docs/content/reference/static-configuration/env-ref.md b/docs/content/reference/static-configuration/env-ref.md index 46e227b085..26e87c629c 100644 --- a/docs/content/reference/static-configuration/env-ref.md +++ b/docs/content/reference/static-configuration/env-ref.md @@ -294,6 +294,9 @@ Prefix to use for metrics collection. (Default: ```traefik```) `TRAEFIK_METRICS_STATSD_PUSHINTERVAL`: StatsD push interval. (Default: ```10```) +`TRAEFIK_PILOT_DASHBOARD`: +Enable Traefik Pilot in the dashboard. (Default: ```true```) + `TRAEFIK_PILOT_TOKEN`: Traefik Pilot token. diff --git a/pkg/config/static/pilot.go b/pkg/config/static/pilot.go index eb56752eec..9b977e790e 100644 --- a/pkg/config/static/pilot.go +++ b/pkg/config/static/pilot.go @@ -2,5 +2,11 @@ package static // Pilot Configuration related to Traefik Pilot. type Pilot struct { - Token string `description:"Traefik Pilot token." json:"token,omitempty" toml:"token,omitempty" yaml:"token,omitempty"` + Token string `description:"Traefik Pilot token." json:"token,omitempty" toml:"token,omitempty" yaml:"token,omitempty"` + Dashboard bool `description:"Enable Traefik Pilot in the dashboard." json:"dashboard,omitempty" toml:"dashboard,omitempty" yaml:"dashboard,omitempty"` +} + +// SetDefaults sets the default values. +func (p *Pilot) SetDefaults() { + p.Dashboard = true } diff --git a/pkg/config/static/static_config.go b/pkg/config/static/static_config.go index 048b87ec7f..3bac3b04ff 100644 --- a/pkg/config/static/static_config.go +++ b/pkg/config/static/static_config.go @@ -231,6 +231,12 @@ func (c *Configuration) SetEffectiveConfiguration() { c.Global.SendAnonymousUsage = true } + // Create Pilot struct to apply default value on undefined configuration. + if c.Pilot == nil { + c.Pilot = &Pilot{} + c.Pilot.SetDefaults() + } + // Disable Gateway API provider if not enabled in experimental if c.Experimental == nil || !c.Experimental.KubernetesGateway { c.Providers.KubernetesGateway = nil diff --git a/pkg/version/version.go b/pkg/version/version.go index c851dc9a3f..ec31b4365f 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -24,6 +24,8 @@ var ( StartDate = time.Now() // UUID instance uuid. UUID string + // PilotEnabled activate integration of pilot into the dashboard. + PilotEnabled bool ) // Handler expose version routes. @@ -38,15 +40,17 @@ func (v Handler) Append(router *mux.Router) { router.Methods(http.MethodGet).Path("/api/version"). HandlerFunc(func(response http.ResponseWriter, request *http.Request) { v := struct { - Version string - Codename string - StartDate time.Time `json:"startDate"` - UUID string `json:"uuid,omitempty"` + Version string + Codename string + StartDate time.Time `json:"startDate"` + UUID string `json:"uuid,omitempty"` + PilotEnabled bool `json:"pilotEnabled"` }{ - Version: Version, - Codename: Codename, - StartDate: StartDate, - UUID: UUID, + Version: Version, + Codename: Codename, + StartDate: StartDate, + UUID: UUID, + PilotEnabled: PilotEnabled, } if err := templatesRenderer.JSON(response, http.StatusOK, v); err != nil { diff --git a/webui/src/App.vue b/webui/src/App.vue index 688e9c440b..bb6e93e606 100644 --- a/webui/src/App.vue +++ b/webui/src/App.vue @@ -1,19 +1,27 @@