diff --git a/docs/content/assets/img/providers/consul.png b/docs/content/assets/img/providers/consul.png index 23a7688c9..a19f0ddf9 100644 Binary files a/docs/content/assets/img/providers/consul.png and b/docs/content/assets/img/providers/consul.png differ diff --git a/docs/content/providers/consul-catalog.md b/docs/content/providers/consul-catalog.md index d387f6ada..0a8486b9e 100644 --- a/docs/content/providers/consul-catalog.md +++ b/docs/content/providers/consul-catalog.md @@ -14,12 +14,12 @@ Attach labels to your services and let Traefik do the rest! Enabling the consulcatalog provider ```toml tab="File (TOML)" - [providers.consulcatalog] + [providers.consulCatalog] ``` ```yaml tab="File (YAML)" providers: - consulcatalog: {} + consulCatalog: {} ``` ```bash tab="CLI" @@ -39,34 +39,19 @@ See the dedicated section in [routing](../routing/providers/consul-catalog.md). ## Provider Configuration -??? tip "Browse the Reference" - If you're in a hurry, maybe you'd rather go through the configuration reference: - - ```toml tab="File (TOML)" - --8<-- "content/providers/consul-catalog.toml" - ``` - - ```yaml tab="File (YAML)" - --8<-- "content/providers/consul-catalog.yml" - ``` - - ```bash tab="CLI" - --8<-- "content/providers/consul-catalog.txt" - ``` - ### `exposedByDefault` _Optional, Default=true_ ```toml tab="File (TOML)" -[providers.consulcatalog] +[providers.consulCatalog] exposedByDefault = false # ... ``` ```yaml tab="File (YAML)" providers: - consulcatalog: + consulCatalog: exposedByDefault: false # ... ``` @@ -86,14 +71,14 @@ See also [Restrict the Scope of Service Discovery](./overview.md#restrict-the-sc _Optional, Default=```Host(`{{ normalize .Name }}`)```_ ```toml tab="File (TOML)" -[providers.consulcatalog] +[providers.consulCatalog] defaultRule = "Host(`{{ .Name }}.{{ index .Labels \"customLabel\"}}`)" # ... ``` ```yaml tab="File (YAML)" providers: - consulcatalog: + consulCatalog: defaultRule: "Host(`{{ .Name }}.{{ index .Labels \"customLabel\"}}`)" # ... ``` @@ -113,92 +98,43 @@ and the template has access to all the labels defined on this container. This option can be overridden on a container basis with the `traefik.http.routers.Router1.rule` label. -### `enableServiceHealthFilter` +### `refreshInterval` -_Optional, Default=true_ +_Optional, Default=15s_ ```toml tab="File (TOML)" -[providers.consulcatalog] - enableServiceHealthFilter = false +[providers.consulCatalog] + refreshInterval = "30s" # ... ``` ```yaml tab="File (YAML)" providers: - consulcatalog: - enableServiceHealthFilter: false + consulCatalog: + refreshInterval: 30s # ... ``` ```bash tab="CLI" ---providers.consulcatalog.enableServiceHealthFilter=false +--providers.consulcatalog.refreshInterval=30s # ... ``` -Filter services with unhealthy states and inactive states. - -### `refreshSeconds` - -_Optional, Default=15_ - -```toml tab="File (TOML)" -[providers.consulcatalog] - refreshSeconds = 30 - # ... -``` - -```yaml tab="File (YAML)" -providers: - consulcatalog: - refreshSeconds: 30 - # ... -``` - -```bash tab="CLI" ---providers.consulcatalog.refreshSeconds=30 -# ... -``` - -Defines the polling interval (in seconds). - -### `intervalPoll` - -_Optional, Default=false_ - -```toml tab="File (TOML)" -[providers.consulcatalog] - intervalPoll = true - # ... -``` - -```yaml tab="File (YAML)" -providers: - consulcatalog: - intervalPoll: true - # ... -``` - -```bash tab="CLI" ---providers.consulcatalog.intervalPoll=true -# ... -``` - -Poll the Consul Catalog metadata service for changes every `consulcatalog.refreshSeconds`, -which is less accurate than the default long polling technique which will provide near instantaneous updates to Traefik. +Defines the polling interval. ### `prefix` _Optional, Default=/latest_ ```toml tab="File (TOML)" -[providers.consulcatalog] +[providers.consulCatalog] prefix = "/test" # ... ``` ```yaml tab="File (YAML)" providers: - consulcatalog: + consulCatalog: prefix: "/test" # ... ``` @@ -208,21 +144,21 @@ providers: # ... ``` -Prefix used for accessing the Consul Catalog service +Prefix used for accessing the Consul service metadata. ### `constraints` _Optional, Default=""_ ```toml tab="File (TOML)" -[providers.consulcatalog] +[providers.consulCatalog] constraints = "Label(`a.label.name`, `foo`)" # ... ``` ```yaml tab="File (YAML)" providers: - consulcatalog: + consulCatalog: constraints: "Label(`a.label.name`, `foo`)" # ... ``` @@ -271,3 +207,325 @@ The expression syntax is based on the `Label("key", "value")`, and `LabelRegex(" ``` See also [Restrict the Scope of Service Discovery](./overview.md#restrict-the-scope-of-service-discovery). + +### `endpoint` + +Defines Consul server endpoint. + +#### `address` + +_Optional, Default="http://127.0.0.1:8500"_ + +```toml tab="File (TOML)" +[providers.consulCatalog] + [providers.consulCatalog.endpoint] + address = "http://127.0.0.1:8500" + # ... +``` + +```yaml tab="File (YAML)" +providers: + consulCatalog: + endpoint: + address: http://127.0.0.1:8500 + # ... +``` + +```bash tab="CLI" +--providers.consulcatalog.endpoint.address=http://127.0.0.1:8500 +# ... +``` + +Defines the address of the Consul server. + +#### `scheme` + +_Optional, Default=""_ + +```toml tab="File (TOML)" +[providers.consulCatalog] + [providers.consulCatalog.endpoint] + scheme = "https" + # ... +``` + +```yaml tab="File (YAML)" +providers: + consulCatalog: + endpoint: + scheme: https + # ... +``` + +```bash tab="CLI" +--providers.consulcatalog.endpoint.scheme=https +# ... +``` + +Defines the URI scheme for the Consul server. + +#### `datacenter` + +_Optional, Default=""_ + +```toml tab="File (TOML)" +[providers.consulCatalog] + [providers.consulCatalog.endpoint] + datacenter = "test" + # ... +``` + +```yaml tab="File (YAML)" +providers: + consulCatalog: + endpoint: + datacenter: test + # ... +``` + +```bash tab="CLI" +--providers.consulcatalog.endpoint.datacenter=test +# ... +``` + +Defines the Data center to use. +If not provided, the default agent data center is used. + +#### `token` + +_Optional, Default=""_ + +```toml tab="File (TOML)" +[providers.consulCatalog] + [providers.consulCatalog.endpoint] + token = "test" + # ... +``` + +```yaml tab="File (YAML)" +providers: + consulCatalog: + endpoint: + token: test + # ... +``` + +```bash tab="CLI" +--providers.consulcatalog.endpoint.token=test +# ... +``` + +Token is used to provide a per-request ACL token which overrides the agent's default token. + +#### `endpointWaitTime` + +_Optional, Default=""_ + +```toml tab="File (TOML)" +[providers.consulCatalog] + [providers.consulCatalog.endpoint] + endpointWaitTime = "15s" + # ... +``` + +```yaml tab="File (YAML)" +providers: + consulCatalog: + endpoint: + endpointWaitTime: 15s + # ... +``` + +```bash tab="CLI" +--providers.consulcatalog.endpoint.endpointwaittime=15s +# ... +``` + +WaitTime limits how long a Watch will block. +If not provided, the agent default values will be used + +#### `httpAuth` + +_Optional_ + +Used to authenticate http client with HTTP Basic Authentication. + +##### `username` + +_Optional_ + +```toml tab="File (TOML)" +[providers.consulCatalog.endpoint.httpAuth] + username = "test" +``` + +```yaml tab="File (YAML)" +providers: + consulCatalog: + endpoint: + httpAuth: + username: test +``` + +```bash tab="CLI" +--providers.consulcatalog.endpoint.httpauth.username=test +``` + +Username to use for HTTP Basic Authentication + +##### `password` + +_Optional_ + +```toml tab="File (TOML)" +[providers.consulCatalog.endpoint.httpAuth] + password = "test" +``` + +```yaml tab="File (YAML)" +providers: + consulCatalog: + endpoint: + httpAuth: + password: test +``` + +```bash tab="CLI" +--providers.consulcatalog.endpoint.httpauth.password=test +``` + +Password to use for HTTP Basic Authentication + +#### `tls` + +_Optional_ + +Defines TLS options for Consul server endpoint. + +##### `ca` + +_Optional_ + +```toml tab="File (TOML)" +[providers.consulCatalog.endpoint.tls] + ca = "path/to/ca.crt" +``` + +```yaml tab="File (YAML)" +providers: + consulCatalog: + endpoint: + tls: + ca: path/to/ca.crt +``` + +```bash tab="CLI" +--providers.consulcatalog.endpoint.tls.ca=path/to/ca.crt +``` + +`ca` is the path to the CA certificate used for Consul communication, defaults to the system bundle if not specified. + +##### `caOptional` + +_Optional_ + +```toml tab="File (TOML)" +[providers.consulCatalog.endpoint.tls] + caOptional = true +``` + +```yaml tab="File (YAML)" +providers: + consulCatalog: + endpoint: + tls: + caOptional: true +``` + +```bash tab="CLI" +--providers.consulcatalog.endpoint.tls.caoptional=true +``` + +Policy followed for the secured connection with TLS Client Authentication to Consul. +Requires `tls.ca` to be defined. + +- `true`: VerifyClientCertIfGiven +- `false`: RequireAndVerifyClientCert +- if `tls.ca` is undefined NoClientCert + +##### `cert` + +_Optional_ + +```toml tab="File (TOML)" +[providers.consulCatalog.endpoint.tls] + cert = "path/to/foo.cert" + key = "path/to/foo.key" +``` + +```yaml tab="File (YAML)" +providers: + consulCatalog: + endpoint: + tls: + cert: path/to/foo.cert + key: path/to/foo.key +``` + +```bash tab="CLI" +--providers.consulcatalog.endpoint.tls.cert=path/to/foo.cert +--providers.consulcatalog.endpoint.tls.key=path/to/foo.key +``` + +`cert` is the path to the public certificate for Consul communication. +If this is set then you need to also set `key. + +##### `key` + +_Optional_ + +```toml tab="File (TOML)" +[providers.consulCatalog.endpoint.tls] + cert = "path/to/foo.cert" + key = "path/to/foo.key" +``` + +```yaml tab="File (YAML)" +providers: + consulCatalog: + endpoint: + tls: + cert: path/to/foo.cert + key: path/to/foo.key +``` + +```bash tab="CLI" +--providers.consulcatalog.endpoint.tls.cert=path/to/foo.cert +--providers.consulcatalog.endpoint.tls.key=path/to/foo.key +``` + +`key` is the path to the private key for Consul communication. +If this is set then you need to also set `cert`. + +##### `insecureSkipVerify` + +_Optional_ + +```toml tab="File (TOML)" +[providers.consulCatalog.endpoint.tls] + insecureSkipVerify = true +``` + +```yaml tab="File (YAML)" +providers: + consulCatalog: + endpoint: + tls: + insecureSkipVerify: true +``` + +```bash tab="CLI" +--providers.consulcatalog.endpoint.tls.insecureskipverify=true +``` + +If `insecureSkipVerify` is `true`, TLS for the connection to Consul server accepts any certificate presented by the server and any host name in that certificate. diff --git a/docs/content/providers/consul-catalog.toml b/docs/content/providers/consul-catalog.toml deleted file mode 100644 index 7915ecfba..000000000 --- a/docs/content/providers/consul-catalog.toml +++ /dev/null @@ -1,44 +0,0 @@ -# Enable Consul Catalog Provider. -[providers.consulcatalog] - - # Expose Consul Catalog services by default in Traefik. - exposedByDefault = true - - # Prefix used for accessing the Consul service metadata. - prefix = "traefik" - - # Defines the polling interval (in seconds). - refreshSeconds = 15 - - # Defines default rule. - defaultRule = "foobar" - - # Defines Consul Catalog Provider endpoint. - [providers.consulcatalog.endpoint] - - # Defines the consul address endpoint. - address = "127.0.0.1:8500" - - # Defines the scheme used. - scheme = "foobar" - - # Defines the DC. - datacenter = "foobar" - - # Defines the token. - token = "foobar" - - # Defines the expoint wait time. - endpointWaitTime = "15s" - - # Defines Consul Catalog Provider TLS endpoint. - [providers.consulcatalog.endpoint.tls] - - # Defines Consul Catalog Provider endpoint. - caOptional = true - - cert = "foobar" - - key = "foobar" - - insecureSkipVerify = true diff --git a/docs/content/providers/consul-catalog.txt b/docs/content/providers/consul-catalog.txt deleted file mode 100644 index 79781aae1..000000000 --- a/docs/content/providers/consul-catalog.txt +++ /dev/null @@ -1,53 +0,0 @@ -# Enable Consul Catalog Provider. ---providers.consulcatalog - -# Enable Consul Catalog Provider constraints. ---providers.consulcatalog.constraints - -# Defines the Consul Catalog default rule. ---providers.consulcatalog.defaultrule - -# Defines the Consul Catalog endpoint address. ---providers.consulcatalog.endpoint.address - -# Defines the Consul Catalog endpoint data-center. ---providers.consulcatalog.endpoint.datacenter - -# Defines the Consul Catalog endpoint wait time. ---providers.consulcatalog.endpoint.endpointwaittime - -# Defines the Consul Catalog endpoint http auth password. ---providers.consulcatalog.endpoint.httpauth.password - -# Defines the Consul Catalog endpoint http auth username. ---providers.consulcatalog.endpoint.httpauth.username - -# Defines the Consul Catalog endpoint scheme. ---providers.consulcatalog.endpoint.scheme - -# Defines the Consul Catalog endpoint tls CA. ---providers.consulcatalog.endpoint.tls.ca - -# Defines the Consul Catalog endpoint tls optional CA. ---providers.consulcatalog.endpoint.tls.caoptional - -# Defines the Consul Catalog endpoint tls cert. ---providers.consulcatalog.endpoint.tls.cert - -# Defines the Consul Catalog endpoint tls insecure skip verify. ---providers.consulcatalog.endpoint.tls.insecureskipverify - -# Defines the Consul Catalog endpoint tls key. ---providers.consulcatalog.endpoint.tls.key - -# Defines the Consul Catalog endpoint token. ---providers.consulcatalog.endpoint.token - -# Defines the Consul Catalog expose by default. ---providers.consulcatalog.exposedbydefault - -# Defines the Consul Catalog prefix. ---providers.consulcatalog.prefix - -# Defines the Consul Catalog refresh interval. ---providers.consulcatalog.refreshinterval diff --git a/docs/content/providers/consul-catalog.yml b/docs/content/providers/consul-catalog.yml deleted file mode 100644 index 734886c0b..000000000 --- a/docs/content/providers/consul-catalog.yml +++ /dev/null @@ -1,31 +0,0 @@ -# Enable Rancher Provider. -providers: - consulcatalog: - - # Expose Consul Catalog services by default in Traefik. - exposedByDefault: true - - # Defines the consul address endpoint. - address: 127.0.0.1:8500 - - # Defines the scheme used. - scheme: "foobar" - - # Defines the DC. - datacenter: "foobar" - - # Defines the token. - token: "foobar" - - # Defines the expoint wait time. - endpointWaitTime: "15s" - - # Defines Consul Catalog Provider TLS endpoint. - endpoint: - tls: - - # Defines Consul Catalog Provider endpoint. - caOptional: true - cert: "foobar" - key: "foobar" - insecureSkipVerify: true diff --git a/docs/content/reference/static-configuration/file.toml b/docs/content/reference/static-configuration/file.toml index 4696c98f6..7a2f4e0e4 100644 --- a/docs/content/reference/static-configuration/file.toml +++ b/docs/content/reference/static-configuration/file.toml @@ -108,19 +108,19 @@ refreshSeconds = 42 intervalPoll = true prefix = "foobar" - [providers.consulcatalog] + [providers.consulCatalog] constraints = "foobar" prefix = "traefik" defaultRule = "foobar" exposedByDefault = true refreshInterval = 15 - [providers.consulcatalog.endpoint] + [providers.consulCatalog.endpoint] address = "foobar" scheme = "foobar" datacenter = "foobar" token = "foobar" endpointWaitTime = "15s" - [providers.consulcatalog.endpoint.tls] + [providers.consulCatalog.endpoint.tls] ca = "foobar" caOptional = true cert = "foobar" diff --git a/docs/content/reference/static-configuration/file.yaml b/docs/content/reference/static-configuration/file.yaml index 114523f2b..5b9d5f5bc 100644 --- a/docs/content/reference/static-configuration/file.yaml +++ b/docs/content/reference/static-configuration/file.yaml @@ -115,7 +115,7 @@ providers: refreshSeconds: 42 intervalPoll: true prefix: foobar - consulcatalog: + consulCatalog: constraints: foobar prefix: traefik defaultRule: foobar diff --git a/integration/fixtures/consul_catalog/default_not_exposed.toml b/integration/fixtures/consul_catalog/default_not_exposed.toml index 49e2bebc9..f47ba97db 100644 --- a/integration/fixtures/consul_catalog/default_not_exposed.toml +++ b/integration/fixtures/consul_catalog/default_not_exposed.toml @@ -13,8 +13,8 @@ insecure = true [providers] - [providers.consulcatalog] + [providers.consulCatalog] exposedByDefault = false refreshInterval = "500ms" - [providers.consulcatalog.endpoint] + [providers.consulCatalog.endpoint] address = "{{ .ConsulAddress }}" diff --git a/integration/fixtures/consul_catalog/simple.toml b/integration/fixtures/consul_catalog/simple.toml index 59506bb1d..93265e7d9 100644 --- a/integration/fixtures/consul_catalog/simple.toml +++ b/integration/fixtures/consul_catalog/simple.toml @@ -13,9 +13,9 @@ insecure = true [providers] - [providers.consulcatalog] + [providers.consulCatalog] exposedByDefault = true refreshInterval = "500ms" defaultRule = "{{ .DefaultRule }}" - [providers.consulcatalog.endpoint] + [providers.consulCatalog.endpoint] address = "{{ .ConsulAddress }}" diff --git a/pkg/config/static/static_config.go b/pkg/config/static/static_config.go index 93f970ff3..9e1aff800 100644 --- a/pkg/config/static/static_config.go +++ b/pkg/config/static/static_config.go @@ -162,7 +162,7 @@ type Providers struct { KubernetesCRD *crd.Provider `description:"Enable Kubernetes backend with default settings." json:"kubernetesCRD,omitempty" toml:"kubernetesCRD,omitempty" yaml:"kubernetesCRD,omitempty" export:"true" label:"allowEmpty"` Rest *rest.Provider `description:"Enable Rest backend with default settings." json:"rest,omitempty" toml:"rest,omitempty" yaml:"rest,omitempty" export:"true" label:"allowEmpty"` Rancher *rancher.Provider `description:"Enable Rancher backend with default settings." json:"rancher,omitempty" toml:"rancher,omitempty" yaml:"rancher,omitempty" export:"true" label:"allowEmpty"` - ConsulCatalog *consulcatalog.Provider `description:"Enable ConsulCatalog backend with default settings." json:"consulcatalog,omitempty" toml:"consulcatalog,omitempty" yaml:"consulcatalog,omitempty"` + ConsulCatalog *consulcatalog.Provider `description:"Enable ConsulCatalog backend with default settings." json:"consulCatalog,omitempty" toml:"consulCatalog,omitempty" yaml:"consulCatalog,omitempty"` } // SetEffectiveConfiguration adds missing configuration parameters derived from existing ones. diff --git a/webui/src/statics/providers/consulcatalog.svg b/webui/src/statics/providers/consulcatalog.svg index 28bbadd24..a692dede2 100644 --- a/webui/src/statics/providers/consulcatalog.svg +++ b/webui/src/statics/providers/consulcatalog.svg @@ -1 +1,10 @@ -Asset 1 \ No newline at end of file + + + + + + + + +