Skip to content

Commit b9f3ed3

Browse files
authored
fix(service)!: align syntax with upstream
1 parent 6ee96be commit b9f3ed3

8 files changed

Lines changed: 97 additions & 135 deletions

File tree

EXAMPLES.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ Or a [global IP on Ingress](https://cloud.google.com/kubernetes-engine/docs/tuto
341341
342342
```yaml
343343
service:
344-
type: NodePort
344+
spec:
345+
type: NodePort
345346
extraObjects:
346347
- apiVersion: networking.k8s.io/v1
347348
kind: Ingress
@@ -364,7 +365,8 @@ ports:
364365
websecure:
365366
appProtocol: HTTPS # Hint for Google L7 load balancer
366367
service:
367-
type: ClusterIP
368+
spec:
369+
type: ClusterIP
368370
extraObjects:
369371
- apiVersion: gateway.networking.k8s.io/v1beta1
370372
kind: Gateway
@@ -552,13 +554,13 @@ PROXY protocol is a protocol for sending client connection information, such as
552554
```yaml
553555
service:
554556
enabled: true
555-
type: LoadBalancer
556557
annotations:
557558
# This will tell DigitalOcean to enable the proxy protocol.
558559
# Note that only REGIONAL type loadbalancers are supported.
559560
# service.beta.kubernetes.io/do-loadbalancer-type: "REGIONAL"
560561
service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: "true"
561562
spec:
563+
type: LoadBalancer
562564
# This is the default and should stay as cluster to keep the DO health checks working.
563565
externalTrafficPolicy: Cluster
564566
@@ -1751,7 +1753,8 @@ gatewayClass:
17511753
service:
17521754
additionalServices:
17531755
external:
1754-
type: LoadBalancer
1756+
spec:
1757+
type: LoadBalancer
17551758
17561759
providers:
17571760
kubernetesGateway:
@@ -1789,3 +1792,11 @@ spec:
17891792
# kind: Secret
17901793
# name: some-tls-cert
17911794
```
1795+
1796+
## Set externalTrafficPolicy Local for Traefik Service
1797+
1798+
```yaml
1799+
service:
1800+
spec:
1801+
externalTrafficPolicy: Local
1802+
```

traefik/VALUES.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,17 +455,14 @@ Kubernetes: `>=1.25.0-0`
455455
| readinessProbe.timeoutSeconds | int | `2` | The number of seconds to wait for a probe response before considering it as failed. |
456456
| resources | object | `{}` | [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) for `traefik` container. |
457457
| securityContext | object | See _values.yaml_ | [SecurityContext](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#security-context-1) |
458-
| service.additionalServices | object | `{}` | |
458+
| service.additionalServices | object | `{}` | Can be used to create multiple Service. See EXAMPLES.md for more details. |
459459
| service.annotations | object | `{}` | Additional annotations applied to both TCP and UDP services (e.g. for cloud provider specific config) |
460460
| service.annotationsTCP | object | `{}` | Additional annotations for TCP service only |
461461
| service.annotationsUDP | object | `{}` | Additional annotations for UDP service only |
462462
| service.enabled | bool | `true` | |
463-
| service.externalIPs | list | `[]` | |
464463
| service.labels | object | `{}` | Additional service labels (e.g. for filtering Service by custom labels) |
465-
| service.loadBalancerSourceRanges | list | `[]` | |
466464
| service.single | bool | `true` | |
467-
| service.spec | object | `{}` | Cannot contain type, selector or ports entries. |
468-
| service.type | string | `"LoadBalancer"` | |
465+
| service.spec | object | `{"type":"LoadBalancer"}` | Additional entries here will be added to the Service [spec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#servicespec-v1-core). Cannot contain selector or ports entries. |
469466
| serviceAccount | object | `{"name":""}` | The service account the pods will use to interact with the Kubernetes API |
470467
| serviceAccountAnnotations | object | `{}` | Additional serviceAccount annotations (e.g. for oidc authentication) |
471468
| startupProbe | object | `{}` | Define [Startup Probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-startup-probes) |

traefik/templates/_service.tpl

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,16 @@
1515
labels:
1616
{{- include "traefik.labels" .root | nindent 4 -}}
1717
{{- with .service.labels }}
18-
{{- toYaml . | nindent 4 }}
18+
{{- toYaml . | nindent 4 }}
1919
{{- end }}
2020
{{- end }}
2121

2222
{{- define "traefik.service-spec" -}}
23-
{{- $type := default "LoadBalancer" .service.type }}
24-
type: {{ $type }}
25-
{{- with .service.loadBalancerClass }}
26-
loadBalancerClass: {{ . }}
27-
{{- end}}
2823
{{- with .service.spec }}
29-
{{- toYaml . | nindent 2 }}
24+
{{- toYaml . | nindent 2 }}
3025
{{- end }}
3126
selector:
3227
{{- include "traefik.labelselector" .root | nindent 4 }}
33-
{{- if eq $type "LoadBalancer" }}
34-
{{- with .service.loadBalancerSourceRanges }}
35-
loadBalancerSourceRanges:
36-
{{- toYaml . | nindent 2 }}
37-
{{- end -}}
38-
{{- end -}}
39-
{{- with .service.externalIPs }}
40-
externalIPs:
41-
{{- toYaml . | nindent 2 }}
42-
{{- end -}}
43-
{{- with .service.ipFamilyPolicy }}
44-
ipFamilyPolicy: {{ . }}
45-
{{- end }}
46-
{{- with .service.ipFamilies }}
47-
ipFamilies:
48-
{{- toYaml . | nindent 2 }}
49-
{{- end -}}
5028
{{- end }}
5129

5230
{{- define "traefik.service-ports" }}

traefik/tests/service-config-custom_test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ tests:
2222
service:
2323
additionalServices:
2424
internal:
25-
type: LoadBalancer
25+
spec:
26+
type: LoadBalancer
2627
asserts:
2728
- equal:
2829
path: spec.type
@@ -221,4 +222,3 @@ tests:
221222
apiVersion: v1
222223
name: RELEASE-NAME-traefik-internal
223224
documentIndex: 1
224-

traefik/tests/service-config-multiple_test.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ tests:
168168
set:
169169
service:
170170
single: false
171-
ipFamilyPolicy: PreferDualStack
171+
spec:
172+
ipFamilyPolicy: PreferDualStack
172173
ports:
173174
udp:
174175
port: 3000
@@ -205,8 +206,9 @@ tests:
205206
set:
206207
service:
207208
single: false
208-
ipFamilies:
209-
- IPv6
209+
spec:
210+
ipFamilies:
211+
- IPv6
210212
ports:
211213
udp:
212214
port: 3000

traefik/tests/service-config_test.yaml

Lines changed: 57 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ tests:
3333
- it: should be a custom type when specified via values
3434
set:
3535
service:
36-
type: NodePort
36+
spec:
37+
type: NodePort
3738
asserts:
3839
- equal:
3940
path: spec.type
@@ -182,7 +183,8 @@ tests:
182183
- it: should have custom ipFamilyPolicy when specified via values
183184
set:
184185
service:
185-
ipFamilyPolicy: PreferDualStack
186+
spec:
187+
ipFamilyPolicy: PreferDualStack
186188
ports:
187189
udp:
188190
port: 3000
@@ -205,8 +207,9 @@ tests:
205207
- it: should have custom ipFamilies when specified via values
206208
set:
207209
service:
208-
ipFamilies:
209-
- IPv6
210+
spec:
211+
ipFamilies:
212+
- IPv6
210213
ports:
211214
udp:
212215
port: 3000
@@ -250,13 +253,13 @@ tests:
250253
enabled: true
251254
documentIndex: 0
252255
asserts:
253-
- contains:
254-
path: spec.ports
255-
content:
256-
port: 443
257-
name: websecure-http3
258-
targetPort: websecure-http3
259-
protocol: UDP
256+
- contains:
257+
path: spec.ports
258+
content:
259+
port: 443
260+
name: websecure-http3
261+
targetPort: websecure-http3
262+
protocol: UDP
260263
- it: should be possible to advertise a different http3 UDP port
261264
set:
262265
ports:
@@ -269,13 +272,13 @@ tests:
269272
enabled: true
270273
documentIndex: 0
271274
asserts:
272-
- contains:
273-
path: spec.ports
274-
content:
275-
port: 4443
276-
name: websecure-http3
277-
targetPort: websecure-http3
278-
protocol: UDP
275+
- contains:
276+
path: spec.ports
277+
content:
278+
port: 4443
279+
name: websecure-http3
280+
targetPort: websecure-http3
281+
protocol: UDP
279282
- it: should split TCP and UDP Service on http3 when single is false
280283
set:
281284
ports:
@@ -285,24 +288,24 @@ tests:
285288
service:
286289
single: false
287290
asserts:
288-
- hasDocuments:
289-
count: 2
290-
- contains:
291-
path: spec.ports
292-
content:
293-
port: 443
294-
name: websecure
295-
targetPort: websecure
296-
protocol: TCP
297-
documentIndex: 0
298-
- contains:
299-
path: spec.ports
300-
content:
301-
port: 443
302-
name: websecure-http3
303-
targetPort: websecure-http3
304-
protocol: UDP
305-
documentIndex: 1
291+
- hasDocuments:
292+
count: 2
293+
- contains:
294+
path: spec.ports
295+
content:
296+
port: 443
297+
name: websecure
298+
targetPort: websecure
299+
protocol: TCP
300+
documentIndex: 0
301+
- contains:
302+
path: spec.ports
303+
content:
304+
port: 443
305+
name: websecure-http3
306+
targetPort: websecure-http3
307+
protocol: UDP
308+
documentIndex: 1
306309
- it: should use advertisedPort with splitted TCP and UDP Service on http3 when single is false
307310
set:
308311
ports:
@@ -313,24 +316,24 @@ tests:
313316
service:
314317
single: false
315318
asserts:
316-
- hasDocuments:
317-
count: 2
318-
- contains:
319-
path: spec.ports
320-
content:
321-
port: 443
322-
name: websecure
323-
targetPort: websecure
324-
protocol: TCP
325-
documentIndex: 0
326-
- contains:
327-
path: spec.ports
328-
content:
329-
port: 4443
330-
name: websecure-http3
331-
targetPort: websecure-http3
332-
protocol: UDP
333-
documentIndex: 1
319+
- hasDocuments:
320+
count: 2
321+
- contains:
322+
path: spec.ports
323+
content:
324+
port: 443
325+
name: websecure
326+
targetPort: websecure
327+
protocol: TCP
328+
documentIndex: 0
329+
- contains:
330+
path: spec.ports
331+
content:
332+
port: 4443
333+
name: websecure-http3
334+
targetPort: websecure-http3
335+
protocol: UDP
336+
documentIndex: 1
334337

335338
- it: should not be possible to use http3 without enabling tls
336339
set:

traefik/values.schema.json

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,6 +2530,7 @@
25302530
"type": "object",
25312531
"properties": {
25322532
"additionalServices": {
2533+
"description": "Can be used to create multiple Service. See EXAMPLES.md for more details.",
25332534
"type": "object"
25342535
},
25352536
"annotations": {
@@ -2547,25 +2548,21 @@
25472548
"enabled": {
25482549
"type": "boolean"
25492550
},
2550-
"externalIPs": {
2551-
"type": "array"
2552-
},
25532551
"labels": {
25542552
"description": "Additional service labels (e.g. for filtering Service by custom labels)",
25552553
"type": "object"
25562554
},
2557-
"loadBalancerSourceRanges": {
2558-
"type": "array"
2559-
},
25602555
"single": {
25612556
"type": "boolean"
25622557
},
25632558
"spec": {
2564-
"description": "Additional entries here will be added to the service spec.",
2565-
"type": "object"
2566-
},
2567-
"type": {
2568-
"type": "string"
2559+
"description": "Additional entries here will be added to the Service [spec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#servicespec-v1-core). Cannot contain selector or ports entries.",
2560+
"type": "object",
2561+
"properties": {
2562+
"type": {
2563+
"type": "string"
2564+
}
2565+
}
25692566
}
25702567
}
25712568
},

0 commit comments

Comments
 (0)