Skip to content

Commit

Permalink
Allow loadbalancer service external IP (#275)
Browse files Browse the repository at this point in the history
Co-authored-by: d3adb5 <[email protected]>
  • Loading branch information
YonatanRubin and d3adb5 authored Jan 8, 2024
1 parent cea7904 commit 7e7b0a8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
8 changes: 8 additions & 0 deletions application/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -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 }}
29 changes: 19 additions & 10 deletions application/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
19 changes: 19 additions & 0 deletions application/tests/notes_test.yaml
Original file line number Diff line number Diff line change
@@ -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:'

0 comments on commit 7e7b0a8

Please sign in to comment.