Skip to content

Commit

Permalink
Drop traefik from default entry points.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Mar 16, 2020
1 parent 5adf74e commit af58faa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/traefik/traefik.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func setupServer(staticConfiguration *static.Configuration) (*server.Server, err
log.WithoutContext().Errorf("Invalid protocol: %v", err)
}

if protocol != "udp" {
if protocol != "udp" && name != static.DefaultInternalEntryPointName {
defaultEntryPoints = append(defaultEntryPoints, name)
}
}
Expand Down
4 changes: 0 additions & 4 deletions integration/testdata/rawdata-ingress.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,24 @@
},
"test-ingress-default-whoami-test-whoami@kubernetes": {
"entryPoints": [
"traefik",
"web"
],
"service": "default-whoami-http",
"rule": "Host(`whoami.test`) \u0026\u0026 PathPrefix(`/whoami`)",
"status": "enabled",
"using": [
"traefik",
"web"
]
},
"test-ingress-https-default-whoami-test-https-whoami@kubernetes": {
"entryPoints": [
"traefik",
"web"
],
"service": "default-whoami-http",
"rule": "Host(`whoami.test.https`) \u0026\u0026 PathPrefix(`/whoami`)",
"tls": {},
"status": "enabled",
"using": [
"traefik",
"web"
]
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/config/static/static_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,14 @@ type Providers struct {
// SetEffectiveConfiguration adds missing configuration parameters derived from existing ones.
// It also takes care of maintaining backwards compatibility.
func (c *Configuration) SetEffectiveConfiguration() {
// Creates the default entry point if needed
if len(c.EntryPoints) == 0 {
ep := &EntryPoint{Address: ":80"}
ep.SetDefaults()
c.EntryPoints = EntryPoints{
"http": ep,
}
c.EntryPoints = EntryPoints{"http": ep}
}

// Creates the internal traefik entry point if needed
if (c.API != nil && c.API.Insecure) ||
(c.Ping != nil && !c.Ping.ManualRouting && c.Ping.EntryPoint == DefaultInternalEntryPointName) ||
(c.Metrics != nil && c.Metrics.Prometheus != nil && !c.Metrics.Prometheus.ManualRouting && c.Metrics.Prometheus.EntryPoint == DefaultInternalEntryPointName) ||
Expand Down
10 changes: 6 additions & 4 deletions pkg/provider/traefik/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"github.com/containous/traefik/v2/pkg/tls"
)

const defaultInternalEntryPointName = "traefik"

var _ provider.Provider = (*Provider)(nil)

// Provider is a provider.Provider implementation that provides the internal routers.
Expand Down Expand Up @@ -137,15 +139,15 @@ func (i *Provider) apiConfiguration(cfg *dynamic.Configuration) {

if i.staticCfg.API.Insecure {
cfg.HTTP.Routers["api"] = &dynamic.Router{
EntryPoints: []string{"traefik"},
EntryPoints: []string{defaultInternalEntryPointName},
Service: "api@internal",
Priority: math.MaxInt32 - 1,
Rule: "PathPrefix(`/api`)",
}

if i.staticCfg.API.Dashboard {
cfg.HTTP.Routers["dashboard"] = &dynamic.Router{
EntryPoints: []string{"traefik"},
EntryPoints: []string{defaultInternalEntryPointName},
Service: "dashboard@internal",
Priority: math.MaxInt32 - 2,
Rule: "PathPrefix(`/`)",
Expand All @@ -166,7 +168,7 @@ func (i *Provider) apiConfiguration(cfg *dynamic.Configuration) {

if i.staticCfg.API.Debug {
cfg.HTTP.Routers["debug"] = &dynamic.Router{
EntryPoints: []string{"traefik"},
EntryPoints: []string{defaultInternalEntryPointName},
Service: "api@internal",
Priority: math.MaxInt32 - 1,
Rule: "PathPrefix(`/debug`)",
Expand Down Expand Up @@ -205,7 +207,7 @@ func (i *Provider) restConfiguration(cfg *dynamic.Configuration) {

if i.staticCfg.Providers.Rest.Insecure {
cfg.HTTP.Routers["rest"] = &dynamic.Router{
EntryPoints: []string{"traefik"},
EntryPoints: []string{defaultInternalEntryPointName},
Service: "rest@internal",
Priority: math.MaxInt32,
Rule: "PathPrefix(`/api/providers`)",
Expand Down

0 comments on commit af58faa

Please sign in to comment.