Skip to content

Commit

Permalink
Chart: Add service cluster IPs. (#12333)
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixDobler authored Nov 12, 2024
1 parent a37994c commit be8abe7
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 0 deletions.
3 changes: 3 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 Expand Up @@ -542,6 +544,7 @@ metadata:
| defaultBackend.replicaCount | int | `1` | |
| defaultBackend.resources | object | `{}` | |
| defaultBackend.service.annotations | object | `{}` | |
| defaultBackend.service.clusterIPs | list | `[]` | Pre-defined cluster internal IP addresses of the default backend 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 |
| defaultBackend.service.externalIPs | list | `[]` | List of IP addresses at which the default backend service is available # Ref: https://kubernetes.io/docs/concepts/services-networking/service/#external-ips # |
| defaultBackend.service.loadBalancerSourceRanges | list | `[]` | |
| defaultBackend.service.servicePort | int | `80` | |
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
24 changes: 24 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,27 @@ tests:
- equal:
path: metadata.name
value: RELEASE-NAME-ingress-nginx-controller-internal

- it: should create a Service without `clusterIPs` if `controller.service.internal.clusterIPs` is not set
set:
controller.service.internal.enabled: true
controller.service.internal.annotations:
test.annotation: "true"
asserts:
- notExists:
path: spec.clusterIPs

- it: should create a Service with `clusterIPs` if `controller.service.internal.clusterIPs` is set
set:
controller.service.internal.enabled: true
controller.service.internal.annotations:
test.annotation: "true"
controller.service.internal.clusterIPs:
- 10.0.0.1
- fd00::1
asserts:
- equal:
path: spec.clusterIPs
value:
- 10.0.0.1
- fd00::1
20 changes: 20 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,23 @@ tests:
- equal:
path: spec.type
value: NodePort

- it: should create a Service without `clusterIPs` if `controller.service.clusterIPs` is not set
set:
controller.service.external.enabled: true
asserts:
- notExists:
path: spec.clusterIPs

- it: should create a Service with `clusterIPs` if `controller.service.clusterIPs` is set
set:
controller.service.external.enabled: true
controller.service.clusterIPs:
- 10.0.0.1
- fd00::1
asserts:
- equal:
path: spec.clusterIPs
value:
- 10.0.0.1
- fd00::1
20 changes: 20 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,23 @@ tests:
- equal:
path: spec.ports[0].port
value: 80

- it: should create a Service without `clusterIPs` if `defaultBackend.service.clusterIPs` is not set
set:
defaultBackend.enabled: true
asserts:
- notExists:
path: spec.clusterIPs

- it: should create a Service with `clusterIPs` if `defaultBackend.service.clusterIPs` is set
set:
defaultBackend.enabled: true
defaultBackend.service.clusterIPs:
- 10.0.0.1
- fd00::1
asserts:
- equal:
path: spec.clusterIPs
value:
- 10.0.0.1
- fd00::1
12 changes: 12 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,10 @@ defaultBackend:
service:
annotations: {}
# clusterIP: ""
# -- Pre-defined cluster internal IP addresses of the default backend 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 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 be8abe7

Please sign in to comment.