diff --git a/application/templates/NOTES.txt b/application/templates/NOTES.txt new file mode 100644 index 00000000..e0c46719 --- /dev/null +++ b/application/templates/NOTES.txt @@ -0,0 +1,8 @@ +{{- if .Values.service.loadBalancerIP }} +service.loadBalancerIP: + You have defined the value of service.loadBalancerIP for this release. Please + be mindful that this field has been deprecated as of Kubernetes v1.24 and may + be removed from the API in a later release. + + Please refer to the Kubernetes documentation for more information. +{{- end }} diff --git a/application/templates/service.yaml b/application/templates/service.yaml index 49b3493f..2286377d 100644 --- a/application/templates/service.yaml +++ b/application/templates/service.yaml @@ -7,20 +7,29 @@ metadata: namespace: {{ template "application.namespace" $ }} labels: {{- include "application.labels" . | nindent 4 }} -{{- if .Values.service.additionalLabels }} -{{ toYaml .Values.service.additionalLabels | indent 4 }} -{{- end }} -{{- if .Values.service.annotations }} + {{- if .Values.service.additionalLabels }} + {{- toYaml .Values.service.additionalLabels | nindent 4 }} + {{- end }} + {{- if .Values.service.annotations }} annotations: -{{ include "application.tplvalues.render" ( dict "value" .Values.service.annotations "context" $ ) | indent 4 }} + {{- include "application.tplvalues.render" ( dict "value" .Values.service.annotations "context" $ ) | nindent 4 }} {{- end }} spec: -{{- if .Values.service.type }} - type: "{{ .Values.service.type }}" -{{- end }} -{{- with .Values.service.clusterIP }} - clusterIP: {{ . }} + type: {{ .Values.service.type }} + clusterIP: {{ .Values.service.clusterIP }} +{{- if eq .Values.service.type "LoadBalancer" }} + {{- with .Values.service.loadBalancerIP }} + loadBalancerIP: {{ . }} + {{- end }} + {{- with .Values.service.loadBalancerSourceRanges }} + loadBalancerSourceRanges: + {{- toYaml . | nindent 4 }} + {{- end }} {{- end }} + {{- with .Values.service.externalIPs }} + externalIPs: + {{- toYaml . | nindent 4 }} + {{- end }} selector: {{ include "application.selectorLabels" . | indent 4 }} {{- if .Values.deployment.podLabels }} diff --git a/application/tests/notes_test.yaml b/application/tests/notes_test.yaml new file mode 100644 index 00000000..c80e08e8 --- /dev/null +++ b/application/tests/notes_test.yaml @@ -0,0 +1,19 @@ +suite: NOTES.txt + +templates: + - NOTES.txt + +tests: + - it: warns the user of the deprecation of loadBalancerIP + set: + service.loadBalancerIP: 1.1.1.1 + asserts: + - matchRegexRaw: + pattern: 'service.loadBalancerIP:' + + - it: does not emit a warning for loadBalancerIP when not set + set: + service.loadBalancerIP: null + asserts: + - notMatchRegexRaw: + pattern: 'service.loadBalancerIP:'