Skip to content

Commit c5d7e2a

Browse files
authored
Merge pull request #5717 from geoblink/feature/add-support-for-internal-load-balancer
Add support for an internal load balancer along with an external one
2 parents 2e5a4bc + 398f548 commit c5d7e2a

File tree

6 files changed

+111
-1
lines changed

6 files changed

+111
-1
lines changed

charts/ingress-nginx/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v1
22
name: ingress-nginx
3-
version: 2.4.0
3+
version: 2.5.0
44
appVersion: 0.33.0
55
home: https://github.com/kubernetes/ingress-nginx
66
description: Ingress controller for Kubernetes using NGINX as a reverse proxy and load balancer

charts/ingress-nginx/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ Parameter | Description | Default
119119
`controller.service.nodePorts.https` | If `controller.service.type` is either `NodePort` or `LoadBalancer` and this is non-empty, it sets the nodePort that maps to the Ingress' port 443 | `""`
120120
`controller.service.nodePorts.tcp` | Sets the nodePort for an entry referenced by its key from `tcp` | `{}`
121121
`controller.service.nodePorts.udp` | Sets the nodePort for an entry referenced by its key from `udp` | `{}`
122+
`controller.service.internal.enabled` | Enables an (additional) internal load balancer | false
123+
`controller.service.internal.annotations` | Annotations for configuring the additional internal load balancer | `{}`
122124
`controller.livenessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | 10
123125
`controller.livenessProbe.periodSeconds` | How often to perform the probe | 10
124126
`controller.livenessProbe.timeoutSeconds` | When the probe times out | 5
@@ -314,6 +316,48 @@ controller:
314316
domainName: "kubernetes-example.com"
315317
```
316318

319+
## Additional internal load balancer
320+
321+
This setup is useful when you need both external and internal load balancers but don't want to have multiple ingress controllers and multiple ingress objects per application.
322+
323+
By default, the ingress object will point to the external load balancer address, but if correctly configured, you can make use of the internal one if the URL you are looking up resolves to the internal load balancer's URL.
324+
325+
You'll need to set both the following values:
326+
327+
`controller.service.internal.enabled`
328+
`controller.service.internal.annotations`
329+
330+
If one of them is missing the internal load balancer will not be deployed. Example you may have `controller.service.internal.enabled=true` but no annotations set, in this case no action will be taken.
331+
332+
`controller.service.internal.annotations` varies with the cloud service you're using.
333+
334+
Example for AWS
335+
```
336+
controller:
337+
service:
338+
internal:
339+
enabled: true
340+
annotations:
341+
# Create internal ELB
342+
service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
343+
# Any other annotation can be declared here.
344+
```
345+
346+
Example for GCE
347+
```
348+
controller:
349+
service:
350+
internal:
351+
enabled: true
352+
annotations:
353+
# Create internal LB
354+
cloud.google.com/load-balancer-type: "Internal"
355+
# Any other annotation can be declared here.
356+
```
357+
358+
An use case for this scenario is having a split-view DNS setup where the public zone CNAME records point to the external balancer URL while the private zone CNAME records point to the internal balancer URL. This way, you only need one ingress kubernetes object.
359+
360+
317361
## Ingress Admission Webhooks
318362
319363
With nginx-ingress-controller version 0.25+, the nginx ingress controller pod exposes an endpoint that will integrate with the `validatingwebhookconfiguration` Kubernetes feature to prevent bad ingress from being added to the cluster.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
controller:
2+
kind: DaemonSet
3+
admissionWebhooks:
4+
enabled: false
5+
service:
6+
type: ClusterIP
7+
internal:
8+
enabled: true
9+
annotations:
10+
service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
controller:
2+
admissionWebhooks:
3+
enabled: false
4+
service:
5+
type: ClusterIP
6+
internal:
7+
enabled: true
8+
annotations:
9+
service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{- if and .Values.controller.service.enabled .Values.controller.service.internal.enabled .Values.controller.service.internal.annotations}}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
annotations:
6+
{{- range $key, $value := .Values.controller.service.internal.annotations }}
7+
{{ $key }}: {{ $value | quote }}
8+
{{- end }}
9+
labels:
10+
{{- include "ingress-nginx.labels" . | nindent 4 }}
11+
app.kubernetes.io/component: controller
12+
{{- if .Values.controller.service.labels }}
13+
{{- toYaml .Values.controller.service.labels | nindent 4 }}
14+
{{- end }}
15+
name: {{ include "ingress-nginx.controller.fullname" . }}-internal
16+
spec:
17+
type: "{{ .Values.controller.service.type }}"
18+
ports:
19+
{{- $setNodePorts := (or (eq .Values.controller.service.type "NodePort") (eq .Values.controller.service.type "LoadBalancer")) }}
20+
{{- if .Values.controller.service.enableHttp }}
21+
- name: http
22+
port: {{ .Values.controller.service.ports.http }}
23+
protocol: TCP
24+
targetPort: {{ .Values.controller.service.targetPorts.http }}
25+
{{- if (and $setNodePorts (not (empty .Values.controller.service.nodePorts.http))) }}
26+
nodePort: {{ .Values.controller.service.nodePorts.http }}
27+
{{- end }}
28+
{{- end }}
29+
{{- if .Values.controller.service.enableHttps }}
30+
- name: https
31+
port: {{ .Values.controller.service.ports.https }}
32+
protocol: TCP
33+
targetPort: {{ .Values.controller.service.targetPorts.https }}
34+
{{- if (and $setNodePorts (not (empty .Values.controller.service.nodePorts.https))) }}
35+
nodePort: {{ .Values.controller.service.nodePorts.https }}
36+
{{- end }}
37+
{{- end }}
38+
selector:
39+
{{- include "ingress-nginx.selectorLabels" . | nindent 4 }}
40+
app.kubernetes.io/component: controller
41+
{{- end }}

charts/ingress-nginx/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@ controller:
302302
tcp: {}
303303
udp: {}
304304

305+
## Enables an additional internal load balancer (besides the external one).
306+
## Annotations are mandatory for the load balancer to come up. Varies with the cloud service.
307+
internal:
308+
enabled: false
309+
annotations: {}
310+
305311
extraContainers: []
306312
## Additional containers to be added to the controller pod.
307313
## See https://github.com/lemonldap-ng-controller/lemonldap-ng-controller as example.

0 commit comments

Comments
 (0)