Skip to content

Commit

Permalink
feat: support custom labels for internal service
Browse files Browse the repository at this point in the history
This change allows configuring labels specifically for the internal
service without affecting the main controller service, useful for
external-dns configuration.

The commit also includes minor YAML indentation fixes in the
deployment template.
  • Loading branch information
samuelarogbonlo committed Jan 14, 2025
1 parent 8da3423 commit 66edf87
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
controller:
name: controller
kind: Deployment
image:
registry: registry.k8s.io
image: ingress-nginx/controller
tag: "v1.12.0"
service:
enabled: true
internal:
enabled: true
type: ClusterIP
labels:
external-dns.alpha.kubernetes.io/hostname: internal.example.com
custom-label: test-value
labels:
regular-service-label: should-not-appear-on-internal
6 changes: 3 additions & 3 deletions charts/ingress-nginx/templates/controller-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ spec:
minReadySeconds: {{ .Values.controller.minReadySeconds }}
template:
metadata:
{{- if .Values.controller.podAnnotations }}
{{- if .Values.controller.podAnnotations }}
annotations:
{{- range $key, $value := .Values.controller.podAnnotations }}
{{- range $key, $value := .Values.controller.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
labels:
{{- include "ingress-nginx.labels" . | nindent 8 }}
app.kubernetes.io/component: controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.controller.service.enabled .Values.controller.service.internal.enabled .Values.controller.service.internal.annotations -}}
{{- if and .Values.controller.service.enabled .Values.controller.service.internal.enabled -}}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -9,8 +9,8 @@ metadata:
labels:
{{- include "ingress-nginx.labels" . | nindent 4 }}
app.kubernetes.io/component: controller
{{- if .Values.controller.service.labels }}
{{- toYaml .Values.controller.service.labels | nindent 4 }}
{{- if .Values.controller.service.internal.labels }}
{{- toYaml .Values.controller.service.internal.labels | nindent 4 }}
{{- end }}
name: {{ include "ingress-nginx.controller.fullname" . }}-internal
namespace: {{ include "ingress-nginx.namespace" . }}
Expand Down
8 changes: 8 additions & 0 deletions charts/ingress-nginx/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ controller:
image:
## Keep false as default for now!
chroot: false
service:
internal:
# Enable the internal service for ingress traffic
enabled: false
# -- Annotations to be added to internal service
annotations: {}
# -- Additional custom labels for internal service specifically, useful for external-dns configuration
labels: {}
# registry: registry.k8s.io
image: ingress-nginx/controller
## for backwards compatibility consider setting the full image url via the repository value below
Expand Down

0 comments on commit 66edf87

Please sign in to comment.