Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ add support for default entrypoints #761

Merged
merged 1 commit into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
{{- range $name, $config := .Values.ports }}
{{- if $config }}
- "--entrypoints.{{$name}}.address=:{{ $config.port }}/{{ default "tcp" $config.protocol | lower }}"
{{- with $config.asDefault }}
{{- if eq ($.Values.experimental.v3.enabled | toString) "false" }}
{{- fail "ERROR: Default entrypoints are only available on Traefik v3. Please set `experimental.v3.enabled` to true and update `image.tag` to `v3.0`." }}
{{- end }}
- "--entrypoints.{{$name}}.asDefault={{ . }}"
{{- end }}
{{- end }}
{{- end }}
- "--api.dashboard=true"
Expand Down
37 changes: 37 additions & 0 deletions traefik/tests/ports-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,40 @@ tests:
path: spec.template.spec.containers[0].args
content: "--entrypoints.udp.address=:51/udp"
template: deployment.yaml

- it: should set entrypoint to default when configured
template: deployment.yaml
set:
experimental:
v3:
enabled: true
ports:
web:
asDefault: true
websecure:
asDefault: false
asserts:
- contains:
path: spec.template.spec.containers[0].args
content: "--entrypoints.web.asDefault=true"
- notContains:
path: spec.template.spec.containers[0].args
content: "--entrypoints.websecure.asDefault=false"
- notContains:
path: spec.template.spec.containers[0].args
content: "--entrypoints.websecure.asDefault=true"

- it: should throw and error when default entrypoint is enabled without traefik v3
template: deployment.yaml
set:
experimental:
v3:
enabled: false
ports:
web:
asDefault: true
websecure:
asDefault: false
asserts:
- failedTemplate:
errorMessage: "Default entrypoints are only available on Traefik v3. Please set `experimental.v3.enabled` to true and update `image.tag` to `v3.0`."
4 changes: 4 additions & 0 deletions traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,8 @@ ports:
# The port protocol (TCP/UDP)
protocol: TCP
web:
## Enable this entrypoint as a default entrypoint. When a service doesn't explicity set an entrypoint it will only use this entrypoint.
# asDefault: true
port: 8000
# hostPort: 8000
expose: true
Expand All @@ -572,6 +574,8 @@ ports:
# trustedIPs: []
# insecure: false
websecure:
## Enable this entrypoint as a default entrypoint. When a service doesn't explicity set an entrypoint it will only use this entrypoint.
# asDefault: true
port: 8443
# hostPort: 8443
expose: true
Expand Down