Skip to content

Commit 63c3306

Browse files
committed
Chart: Add .spec.trafficDistribution support for controller services
Add support for `.spec.trafficDistribution` field in controller service configuration to route traffic to endpoints that are topologically closer to the client. Ref: https://kubernetes.io/docs/concepts/services-networking/service/#traffic-distribution Signed-off-by: Aofei Sheng <[email protected]>
1 parent bd3ee3e commit 63c3306

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

charts/ingress-nginx/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ metadata:
468468
| controller.service.internal.ports | object | `{}` | |
469469
| controller.service.internal.sessionAffinity | string | `""` | Session affinity of the internal controller service. Must be either "None" or "ClientIP" if set. Defaults to "None". Ref: https://kubernetes.io/docs/reference/networking/virtual-ips/#session-affinity |
470470
| controller.service.internal.targetPorts | object | `{}` | |
471+
| controller.service.internal.trafficDistribution | string | `""` | Traffic distribution policy of the internal controller service. Set to "PreferClose" to route traffic to endpoints that are topologically closer to the client. Ref: https://kubernetes.io/docs/concepts/services-networking/service/#traffic-distribution |
471472
| controller.service.internal.type | string | `""` | Type of the internal controller service. Defaults to the value of `controller.service.type`. Ref: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types |
472473
| controller.service.ipFamilies | list | `["IPv4"]` | List of IP families (e.g. IPv4, IPv6) assigned to the external controller service. This field is usually assigned automatically based on cluster configuration and the `ipFamilyPolicy` field. Ref: https://kubernetes.io/docs/concepts/services-networking/dual-stack/#services |
473474
| controller.service.ipFamilyPolicy | string | `"SingleStack"` | Represents the dual-stack capabilities of the external controller service. Possible values are SingleStack, PreferDualStack or RequireDualStack. Fields `ipFamilies` and `clusterIP` depend on the value of this field. Ref: https://kubernetes.io/docs/concepts/services-networking/dual-stack/#services |
@@ -484,6 +485,7 @@ metadata:
484485
| controller.service.sessionAffinity | string | `""` | Session affinity of the external controller service. Must be either "None" or "ClientIP" if set. Defaults to "None". Ref: https://kubernetes.io/docs/reference/networking/virtual-ips/#session-affinity |
485486
| controller.service.targetPorts.http | string | `"http"` | Port of the ingress controller the external HTTP listener is mapped to. |
486487
| controller.service.targetPorts.https | string | `"https"` | Port of the ingress controller the external HTTPS listener is mapped to. |
488+
| controller.service.trafficDistribution | string | `""` | Traffic distribution policy of the external controller service. Set to "PreferClose" to route traffic to endpoints that are topologically closer to the client. Ref: https://kubernetes.io/docs/concepts/services-networking/service/#traffic-distribution |
487489
| controller.service.type | string | `"LoadBalancer"` | Type of the external controller service. Ref: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types |
488490
| controller.shareProcessNamespace | bool | `false` | |
489491
| controller.sysctls | object | `{}` | sysctls for controller pods # Ref: https://kubernetes.io/docs/tasks/administer-cluster/sysctl-cluster/ |

charts/ingress-nginx/templates/controller-service-internal.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ spec:
3737
{{- if hasKey .Values.controller.service.internal "allocateLoadBalancerNodePorts" }}
3838
allocateLoadBalancerNodePorts: {{ .Values.controller.service.internal.allocateLoadBalancerNodePorts }}
3939
{{- end }}
40+
{{- if .Values.controller.service.internal.trafficDistribution }}
41+
trafficDistribution: {{ .Values.controller.service.internal.trafficDistribution }}
42+
{{- end }}
4043
{{- if .Values.controller.service.internal.externalTrafficPolicy }}
4144
externalTrafficPolicy: {{ .Values.controller.service.internal.externalTrafficPolicy }}
4245
{{- end }}

charts/ingress-nginx/templates/controller-service.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ spec:
3737
{{- if hasKey .Values.controller.service "allocateLoadBalancerNodePorts" }}
3838
allocateLoadBalancerNodePorts: {{ .Values.controller.service.allocateLoadBalancerNodePorts }}
3939
{{- end }}
40+
{{- if .Values.controller.service.trafficDistribution }}
41+
trafficDistribution: {{ .Values.controller.service.trafficDistribution }}
42+
{{- end }}
4043
{{- if .Values.controller.service.externalTrafficPolicy }}
4144
externalTrafficPolicy: {{ .Values.controller.service.externalTrafficPolicy }}
4245
{{- end }}

charts/ingress-nginx/tests/controller-service-internal_test.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,14 @@ tests:
4747
value:
4848
- 10.0.0.1
4949
- fd00::1
50+
51+
- it: should create a Service with `trafficDistribution` when specified for internal service
52+
set:
53+
controller.service.internal.enabled: true
54+
controller.service.internal.annotations:
55+
test.annotation: "true"
56+
controller.service.internal.trafficDistribution: PreferClose
57+
asserts:
58+
- equal:
59+
path: spec.trafficDistribution
60+
value: PreferClose

charts/ingress-nginx/tests/controller-service_test.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,12 @@ tests:
5050
value:
5151
- 10.0.0.1
5252
- fd00::1
53+
54+
- it: should create a Service with `trafficDistribution` when specified for external service
55+
set:
56+
controller.service.external.enabled: true
57+
controller.service.trafficDistribution: PreferClose
58+
asserts:
59+
- equal:
60+
path: spec.trafficDistribution
61+
value: PreferClose

charts/ingress-nginx/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,10 @@ controller:
527527
# Ref: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip
528528
# healthCheckNodePort: 0
529529

530+
# -- Traffic distribution policy of the external controller service. Set to "PreferClose" to route traffic to endpoints that are topologically closer to the client.
531+
# Ref: https://kubernetes.io/docs/concepts/services-networking/service/#traffic-distribution
532+
trafficDistribution: ""
533+
530534
# -- Represents the dual-stack capabilities of the external controller service. Possible values are SingleStack, PreferDualStack or RequireDualStack.
531535
# Fields `ipFamilies` and `clusterIP` depend on the value of this field.
532536
# Ref: https://kubernetes.io/docs/concepts/services-networking/dual-stack/#services
@@ -600,6 +604,10 @@ controller:
600604
# Ref: https://kubernetes.io/docs/concepts/services-networking/service/#load-balancer-nodeport-allocation
601605
# allocateLoadBalancerNodePorts: true
602606

607+
# -- Traffic distribution policy of the internal controller service. Set to "PreferClose" to route traffic to endpoints that are topologically closer to the client.
608+
# Ref: https://kubernetes.io/docs/concepts/services-networking/service/#traffic-distribution
609+
trafficDistribution: ""
610+
603611
# -- External traffic policy of the internal controller service. Set to "Local" to preserve source IP on providers supporting it.
604612
# Ref: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip
605613
externalTrafficPolicy: ""

0 commit comments

Comments
 (0)