Skip to content

Commit

Permalink
feat: ✨ add missing consulCatalogEnterprise provider for Hub
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweaver87 committed Jan 29, 2025
1 parent c3f28c7 commit da3b51f
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 0 deletions.
27 changes: 27 additions & 0 deletions traefik/VALUES.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,33 @@ Kubernetes: `>=1.22.0-0`
| hub.apimanagement.enabled | bool | `false` | Set to true in order to enable API Management. Requires a valid license token. |
| hub.apimanagement.openApi.validateRequestMethodAndPath | bool | `false` | When set to true, it will only accept paths and methods that are explicitly defined in its OpenAPI specification |
| hub.experimental.aigateway | bool | `false` | Set to true in order to enable AI Gateway. Requires a valid license token. |
| hub.providers.consulCatalogEnterprise.cache | bool | `false` | Use local agent caching for catalog reads. |
| hub.providers.consulCatalogEnterprise.connectAware | bool | `false` | Enable Consul Connect support. |
| hub.providers.consulCatalogEnterprise.connectByDefault | bool | `false` | Consider every service as Connect capable by default. |
| hub.providers.consulCatalogEnterprise.constraints | string | `""` | Constraints is an expression that Traefik matches against the container's labels |
| hub.providers.consulCatalogEnterprise.defaultRule | string | `"Host(`{{ normalize .Name }}`)"` | Default rule. |
| hub.providers.consulCatalogEnterprise.enabled | bool | `false` | Enable Consul Catalog Enterprise backend with default settings. |
| hub.providers.consulCatalogEnterprise.endpoint.address | string | `""` | The address of the Consul server |
| hub.providers.consulCatalogEnterprise.endpoint.datacenter | string | `""` | Data center to use. If not provided, the default agent data center is used |
| hub.providers.consulCatalogEnterprise.endpoint.endpointWaitTime | int | `0` | WaitTime limits how long a Watch will block. If not provided, the agent default |
| hub.providers.consulCatalogEnterprise.endpoint.httpauth.password | string | `""` | Basic Auth password |
| hub.providers.consulCatalogEnterprise.endpoint.httpauth.username | string | `""` | Basic Auth username |
| hub.providers.consulCatalogEnterprise.endpoint.scheme | string | `""` | The URI scheme for the Consul server |
| hub.providers.consulCatalogEnterprise.endpoint.tls.ca | string | `""` | TLS CA |
| hub.providers.consulCatalogEnterprise.endpoint.tls.cert | string | `""` | TLS cert |
| hub.providers.consulCatalogEnterprise.endpoint.tls.insecureSkipVerify | bool | `false` | TLS insecure skip verify |
| hub.providers.consulCatalogEnterprise.endpoint.tls.key | string | `""` | TLS key |
| hub.providers.consulCatalogEnterprise.endpoint.token | string | `""` | Token is used to provide a per-request ACL token which overrides the agent's |
| hub.providers.consulCatalogEnterprise.exposedByDefault | bool | `true` | Expose containers by default. |
| hub.providers.consulCatalogEnterprise.namespaces | string | `""` | Sets the namespaces used to discover services (Consul Enterprise only). |
| hub.providers.consulCatalogEnterprise.partition | string | `""` | Sets the partition used to discover services (Consul Enterprise only). |
| hub.providers.consulCatalogEnterprise.prefix | string | `"traefik"` | Prefix for consul service tags. |
| hub.providers.consulCatalogEnterprise.refreshInterval | int | `15` | Interval for check Consul API. |
| hub.providers.consulCatalogEnterprise.requireConsistent | bool | `false` | Forces the read to be fully consistent. |
| hub.providers.consulCatalogEnterprise.serviceName | string | `"traefik"` | Name of the Traefik service in Consul Catalog (needs to be registered via the |
| hub.providers.consulCatalogEnterprise.stale | bool | `false` | Use stale consistency for catalog reads. |
| hub.providers.consulCatalogEnterprise.strictChecks | string | `"passing, warning"` | A list of service health statuses to allow taking traffic. |
| hub.providers.consulCatalogEnterprise.watch | bool | `false` | Watch Consul API events. |
| hub.redis.cluster | string | `nil` | Enable Redis Cluster. Default: true. |
| hub.redis.database | string | `nil` | Database used to store information. Default: "0". |
| hub.redis.endpoints | string | `""` | Endpoints of the Redis instances to connect to. Default: "". |
Expand Down
3 changes: 3 additions & 0 deletions traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,9 @@
{{- if and $.Values.tracing.otlp.enabled .tracing.additionalTraceHeaders.enabled }}
{{- include "traefik.yaml2CommandLineArgs" (dict "path" "hub.tracing.additionalTraceHeaders.traceContext" "content" $.Values.hub.tracing.additionalTraceHeaders.traceContext) | nindent 10 }}
{{- end }}
{{- if .providers.consulCatalogEnterprise.enabled }}
{{- include "traefik.yaml2CommandLineArgs" (dict "path" "hub.providers.consulCatalogEnterprise" "content" (omit $.Values.hub.providers.consulCatalogEnterprise "enabled")) | nindent 10 }}
{{- end }}
{{- end }}
{{- end }}
env:
Expand Down
4 changes: 4 additions & 0 deletions traefik/templates/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,8 @@
{{- if and (not $.Values.tracing.otlp.enabled) .Values.hub.tracing.additionalTraceHeaders.enabled }}
{{ fail "ERROR: additionalTraceHeaders needs tracing.otlp to be enabled."}}
{{- end }}

{{- if and (semverCompare "<v3.6.0" $hubVersion) .Values.hub.providers.consulCatalogEnterprise.enabled }}
{{ fail "ERROR: consulCatalogEnterprise provider is a feature only available for traefik-hub >= v3.6.0."}}
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions traefik/tests/requirements-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,15 @@ tests:
asserts:
- failedTemplate:
errorMessage: "ERROR: additionalTraceHeaders needs tracing.otlp to be enabled."
- it: should fail when using consulCatalogEnterprise provider on hub < 3.6.0
set:
image:
tag: v3.5.0
hub:
token: "xxx"
providers:
consulCatalogEnterprise:
enabled: true
asserts:
- failedTemplate:
errorMessage: "ERROR: consulCatalogEnterprise provider is a feature only available for traefik-hub >= v3.6.0."
18 changes: 18 additions & 0 deletions traefik/tests/traefik-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -812,3 +812,21 @@ tests:
- contains:
path: spec.template.spec.containers[0].args
content: "--hub.tracing.additionalTraceHeaders.traceContext.traceState=traceState"
- it: should be possible to configure Traefik Hub consulCatalogEnterprise provider
set:
image:
tag: v3.9.0
tracing:
otlp:
enabled: true
hub:
token: "xxx"
providers:
consulCatalogEnterprise:
enabled: true
prefix: "traefikprefix"

asserts:
- contains:
path: spec.template.spec.containers[0].args
content: "--hub.providers.consulCatalogEnterprise.prefix=traefikprefix"
106 changes: 106 additions & 0 deletions traefik/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,112 @@
},
"type": "object"
},
"providers": {
"properties": {
"consulCatalogEnterprise": {
"properties": {
"cache": {
"type": "boolean"
},
"connectAware": {
"type": "boolean"
},
"connectByDefault": {
"type": "boolean"
},
"constraints": {
"type": "string"
},
"defaultRule": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"endpoint": {
"properties": {
"address": {
"type": "string"
},
"datacenter": {
"type": "string"
},
"endpointWaitTime": {
"type": "integer"
},
"httpauth": {
"properties": {
"password": {
"type": "string"
},
"username": {
"type": "string"
}
},
"type": "object"
},
"scheme": {
"type": "string"
},
"tls": {
"properties": {
"ca": {
"type": "string"
},
"cert": {
"type": "string"
},
"insecureSkipVerify": {
"type": "boolean"
},
"key": {
"type": "string"
}
},
"type": "object"
},
"token": {
"type": "string"
}
},
"type": "object"
},
"exposedByDefault": {
"type": "boolean"
},
"namespaces": {
"type": "string"
},
"partition": {
"type": "string"
},
"prefix": {
"type": "string"
},
"refreshInterval": {
"type": "integer"
},
"requireConsistent": {
"type": "boolean"
},
"serviceName": {
"type": "string"
},
"stale": {
"type": "boolean"
},
"strictChecks": {
"type": "string"
},
"watch": {
"type": "boolean"
}
},
"type": "object"
}
},
"type": "object"
},
"redis": {
"properties": {
"cluster": {
Expand Down
60 changes: 60 additions & 0 deletions traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,66 @@ hub:
insecureSkipVerify: false
# Enable export of errors logs to the platform. Default: true.
sendlogs: # @schema type:[boolean, null]
providers:
consulCatalogEnterprise:
# -- Enable Consul Catalog Enterprise backend with default settings.
enabled: false
# -- Use local agent caching for catalog reads.
cache: false
# -- Enable Consul Connect support.
connectAware: false
# -- Consider every service as Connect capable by default.
connectByDefault: false
# -- Constraints is an expression that Traefik matches against the container's labels
constraints: ""
# -- Default rule.
defaultRule: "Host(`{{ normalize .Name }}`)"
endpoint:
# -- The address of the Consul server
address: ""
# -- Data center to use. If not provided, the default agent data center is used
datacenter: ""
# -- WaitTime limits how long a Watch will block. If not provided, the agent default
endpointWaitTime: 0
httpauth:
# -- Basic Auth password
password: ""
# -- Basic Auth username
username: ""
# -- The URI scheme for the Consul server
scheme: ""
tls:
# -- TLS CA
ca: ""
# -- TLS cert
cert: ""
# -- TLS insecure skip verify
insecureSkipVerify: false
# -- TLS key
key: ""
# -- Token is used to provide a per-request ACL token which overrides the agent's
token: ""
# -- Expose containers by default.
exposedByDefault: true
# -- Sets the namespaces used to discover services (Consul Enterprise only).
namespaces: ""
# -- Sets the partition used to discover services (Consul Enterprise only).
partition: ""
# -- Prefix for consul service tags.
prefix: "traefik"
# -- Interval for check Consul API.
refreshInterval: 15
# -- Forces the read to be fully consistent.
requireConsistent: false
# -- Name of the Traefik service in Consul Catalog (needs to be registered via the
serviceName: "traefik"
# -- Use stale consistency for catalog reads.
stale: false
# -- A list of service health statuses to allow taking traffic.
strictChecks: "passing, warning"
# -- Watch Consul API events.
watch: false

tracing:
# -- Tracing headers to duplicate.
# To configure the following, tracing.otlp.enabled needs to be set to true.
Expand Down

0 comments on commit da3b51f

Please sign in to comment.