Skip to content

Commit

Permalink
Chart: Add support for Service ClusterIPs Value
Browse files Browse the repository at this point in the history
Chart: Add documentation for new Service clusterIPs value

Chart: Add tests for clusterIPs
  • Loading branch information
FelixDobler committed Nov 12, 2024
1 parent a37994c commit df71940
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 0 deletions.
2 changes: 2 additions & 0 deletions charts/ingress-nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ metadata:
| controller.service.annotations | object | `{}` | Annotations to be added to the external controller service. See `controller.service.internal.annotations` for annotations to be added to the internal controller service. |
| controller.service.appProtocol | bool | `true` | Declare the app protocol of the external HTTP and HTTPS listeners or not. Supersedes provider-specific annotations for declaring the backend protocol. Ref: https://kubernetes.io/docs/concepts/services-networking/service/#application-protocol |
| controller.service.clusterIP | string | `""` | Pre-defined cluster internal IP address of the external controller service. Take care of collisions with existing services. This value is immutable. Set once, it can not be changed without deleting and re-creating the service. Ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address |
| controller.service.clusterIPs | list | `[]` | Pre-defined cluster internal IP addresses of the external controller service. Take care of collisions with existing services. This value is immutable. Set once, it can not be changed without deleting and re-creating the service. Ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address |
| controller.service.enableHttp | bool | `true` | Enable the HTTP listener on both controller services or not. |
| controller.service.enableHttps | bool | `true` | Enable the HTTPS listener on both controller services or not. |
| controller.service.enabled | bool | `true` | Enable controller services or not. This does not influence the creation of either the admission webhook or the metrics service. |
Expand All @@ -451,6 +452,7 @@ metadata:
| controller.service.internal.annotations | object | `{}` | Annotations to be added to the internal controller service. Mandatory for the internal controller service to be created. Varies with the cloud service. Ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer |
| controller.service.internal.appProtocol | bool | `true` | Declare the app protocol of the internal HTTP and HTTPS listeners or not. Supersedes provider-specific annotations for declaring the backend protocol. Ref: https://kubernetes.io/docs/concepts/services-networking/service/#application-protocol |
| controller.service.internal.clusterIP | string | `""` | Pre-defined cluster internal IP address of the internal controller service. Take care of collisions with existing services. This value is immutable. Set once, it can not be changed without deleting and re-creating the service. Ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address |
| controller.service.internal.clusterIPs | list | `[]` | Pre-defined cluster internal IP addresses of the internal controller service. Take care of collisions with existing services. This value is immutable. Set once, it can not be changed without deleting and re-creating the service. Ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address |
| controller.service.internal.enabled | bool | `false` | Enable the internal controller service or not. Remember to configure `controller.service.internal.annotations` when enabling this. |
| controller.service.internal.externalIPs | list | `[]` | List of node IP addresses at which the internal controller service is available. Ref: https://kubernetes.io/docs/concepts/services-networking/service/#external-ips |
| controller.service.internal.externalTrafficPolicy | string | `""` | External traffic policy of the internal controller service. Set to "Local" to preserve source IP on providers supporting it. Ref: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ spec:
{{- if .Values.controller.service.internal.clusterIP }}
clusterIP: {{ .Values.controller.service.internal.clusterIP }}
{{- end }}
{{- if .Values.controller.service.internal.clusterIPs }}
clusterIPs: {{ toYaml .Values.controller.service.internal.clusterIPs | nindent 4 }}
{{- end }}
{{- if .Values.controller.service.internal.externalIPs }}
externalIPs: {{ toYaml .Values.controller.service.internal.externalIPs | nindent 4 }}
{{- end }}
Expand Down
3 changes: 3 additions & 0 deletions charts/ingress-nginx/templates/controller-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ spec:
{{- if .Values.controller.service.clusterIP }}
clusterIP: {{ .Values.controller.service.clusterIP }}
{{- end }}
{{- if .Values.controller.service.clusterIPs }}
clusterIPs: {{ toYaml .Values.controller.service.clusterIPs | nindent 4 }}
{{- end }}
{{- if .Values.controller.service.externalIPs }}
externalIPs: {{ toYaml .Values.controller.service.externalIPs | nindent 4 }}
{{- end }}
Expand Down
3 changes: 3 additions & 0 deletions charts/ingress-nginx/templates/default-backend-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ spec:
{{- if .Values.defaultBackend.service.clusterIP }}
clusterIP: {{ .Values.defaultBackend.service.clusterIP }}
{{- end }}
{{- if .Values.defaultBackend.service.clusterIPs }}
clusterIPs: {{ toYaml .Values.defaultBackend.service.clusterIPs | nindent 4 }}
{{- end }}
{{- if .Values.defaultBackend.service.externalIPs }}
externalIPs: {{ toYaml .Values.defaultBackend.service.externalIPs | nindent 4 }}
{{- end }}
Expand Down
32 changes: 32 additions & 0 deletions charts/ingress-nginx/tests/controller-service-internal_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,35 @@ tests:
- equal:
path: metadata.name
value: RELEASE-NAME-ingress-nginx-controller-internal

- it: should add clusterIPs to an internal Service if `controller.service.internal.clusterIPs` are set
set:
controller.service.internal.enabled: true
controller.service.internal.annotations:
test.annotation: "true"
controller.service.internal.clusterIPs: &clusterIPs-value
- 10.0.0.1
- fd00::1
asserts:
- equal:
path: spec.clusterIPs
value: *clusterIPs-value

- it: should not add clusterIPs to an internal Service if `controller.service.internal.clusterIPs` does not exist
set:
controller.service.internal.enabled: true
controller.service.internal.annotations:
test.annotation: "true"
asserts:
- notExists:
path: spec.clusterIPs

- it: should not add clusterIPs to an internal Service if `controller.service.internal.clusterIPs` is an empty array
set:
controller.service.internal.enabled: true
controller.service.internal.annotations:
test.annotation: "true"
controller.service.internal.clusterIPs: []
asserts:
- notExists:
path: spec.clusterIPs
26 changes: 26 additions & 0 deletions charts/ingress-nginx/tests/controller-service_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,29 @@ tests:
- equal:
path: spec.type
value: NodePort

- it: should add clusterIPs to an external Service if `controller.service.clusterIPs` are set
set:
controller.service.external.enabled: true
controller.service.clusterIPs: &clusterIPs-value
- 10.0.0.1
- fd00::1
asserts:
- equal:
path: spec.clusterIPs
value: *clusterIPs-value

- it: should not add clusterIPs to an external Service if `controller.service.clusterIPs` does not exist
set:
controller.service.external.enabled: true
asserts:
- notExists:
path: spec.clusterIPs

- it: should not add clusterIPs to an external Service if `controller.service.clusterIPs` is an empty array
set:
controller.service.external.enabled: true
controller.service.clusterIPs: []
asserts:
- notExists:
path: spec.clusterIPs
26 changes: 26 additions & 0 deletions charts/ingress-nginx/tests/default-backend-service_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,29 @@ tests:
- equal:
path: spec.ports[0].port
value: 80

- it: should add clusterIPs to the default backend service if `defaultBackend.service.clusterIPs` are set
set:
defaultBackend.enabled: true
defaultBackend.service.clusterIPs: &clusterIPs-value
- 10.0.0.1
- fd00::1
asserts:
- equal:
path: spec.clusterIPs
value: *clusterIPs-value

- it: should not add clusterIPs to the default backend service if `defaultBackend.service.clusterIPs` does not exist
set:
defaultBackend.enabled: true
asserts:
- notExists:
path: spec.clusterIPs

- it: should not add clusterIPs to the default backend service if `defaultBackend.service.clusterIPs` is an empty array
set:
defaultBackend.enabled: true
defaultBackend.service.clusterIPs: []
asserts:
- notExists:
path: spec.clusterIPs
9 changes: 9 additions & 0 deletions charts/ingress-nginx/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,10 @@ controller:
# This value is immutable. Set once, it can not be changed without deleting and re-creating the service.
# Ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address
clusterIP: ""
# -- Pre-defined cluster internal IP addresses of the external controller service. Take care of collisions with existing services.
# This value is immutable. Set once, it can not be changed without deleting and re-creating the service.
# Ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address
clusterIPs: []
# -- List of node IP addresses at which the external controller service is available.
# Ref: https://kubernetes.io/docs/concepts/services-networking/service/#external-ips
externalIPs: []
Expand Down Expand Up @@ -577,6 +581,10 @@ controller:
# This value is immutable. Set once, it can not be changed without deleting and re-creating the service.
# Ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address
clusterIP: ""
# -- Pre-defined cluster internal IP addresses of the internal controller service. Take care of collisions with existing services.
# This value is immutable. Set once, it can not be changed without deleting and re-creating the service.
# Ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address
clusterIPs: []
# -- List of node IP addresses at which the internal controller service is available.
# Ref: https://kubernetes.io/docs/concepts/services-networking/service/#external-ips
externalIPs: []
Expand Down Expand Up @@ -1155,6 +1163,7 @@ defaultBackend:
service:
annotations: {}
# clusterIP: ""
# clusterIPs: []

# -- List of IP addresses at which the default backend service is available
## Ref: https://kubernetes.io/docs/concepts/services-networking/service/#external-ips
Expand Down

0 comments on commit df71940

Please sign in to comment.