Skip to content

Commit

Permalink
Add appProtocol field
Browse files Browse the repository at this point in the history
Since Kubernetes 1.20, the `.spec.ports[*].appProtocol` field may be set on a Service as a hint for implementations to offer richer behavior for protocols that they understand. For example, this field is used by the GKE Gateway controller to enable TLS between the load balancer and the backend.
  • Loading branch information
baarde authored and traefiker committed Jun 6, 2023
1 parent 78cb8f1 commit 2706a25
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions traefik/templates/_service.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
{{- if $config.nodePort }}
nodePort: {{ $config.nodePort }}
{{- end }}
{{- if $config.appProtocol }}
appProtocol: {{ $config.appProtocol }}
{{- end }}
{{- end }}
{{- if $config.http3 }}
{{- if $config.http3.enabled }}
Expand All @@ -57,6 +60,9 @@
{{- if $config.nodePort }}
nodePort: {{ $config.nodePort }}
{{- end }}
{{- if $config.appProtocol }}
appProtocol: {{ $config.appProtocol }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
22 changes: 22 additions & 0 deletions traefik/tests/service-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,28 @@ tests:
value:
- IPv6
documentIndex: 0
- it: should not have appProtocol when not specified
documentIndex: 0
asserts:
- isNull:
path: spec.ports[0].appProtocol
- isNull:
path: spec.ports[1].appProtocol
- it: should have custom appProtocol when specified via values
set:
ports:
web:
appProtocol: http
websecure:
appProtocol: https
documentIndex: 0
asserts:
- equal:
path: spec.ports[0].appProtocol
value: http
- equal:
path: spec.ports[1].appProtocol
value: https
- it: should use default websecure UDP port when http3 is enabled
set:
ports:
Expand Down
2 changes: 2 additions & 0 deletions traefik/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,8 @@ ports:
## -- The port protocol (TCP/UDP)
protocol: TCP
# nodePort: 32443
## -- Specify an application protocol. This may be used as a hint for a Layer 7 load balancer.
# appProtocol: https
#
## -- Enable HTTP/3 on the entrypoint
## Enabling it will also enable http3 experimental feature
Expand Down

0 comments on commit 2706a25

Please sign in to comment.