diff --git a/haproxy/Chart.yaml b/haproxy/Chart.yaml index fdb4398..5666c2b 100644 --- a/haproxy/Chart.yaml +++ b/haproxy/Chart.yaml @@ -16,7 +16,7 @@ apiVersion: v2 name: haproxy description: A Helm chart for HAProxy on Kubernetes type: application -version: 1.21.0 +version: 1.22.0 appVersion: 2.9.5 kubeVersion: ">=1.17.0-0" keywords: @@ -31,6 +31,4 @@ maintainers: engine: gotpl annotations: artifacthub.io/changes: | - - Update base image to HAProxy 2.9.5 - - Add internalTrafficPolicy property for service (#218) - - Update podAnnotations rendering for better flexibility (#224) + - Add support NodePort service (#234) diff --git a/haproxy/templates/NOTES.txt b/haproxy/templates/NOTES.txt index e46f588..c23fa49 100644 --- a/haproxy/templates/NOTES.txt +++ b/haproxy/templates/NOTES.txt @@ -5,11 +5,16 @@ Controller image deployed is: "{{ .Values.image.repository }}:{{ tpl .Values.ima Your HAProxy app is of a "{{ .Values.kind }}" kind. Service ports mapped are: +{{- $nodePorts := .Values.service.nodePorts }} +{{- $servicePortType := .Values.service.type }} {{- if eq .Values.kind "Deployment" }} {{- range $key, $value := .Values.containerPorts }} - name: {{ $key }} containerPort: {{ $value }} protocol: TCP + {{- if and (hasKey $nodePorts $key) (eq $servicePortType "NodePort") }} + nodePort: {{ get $nodePorts $key }} + {{- end }} {{- end }} {{- end }} {{- if eq .Values.kind "DaemonSet" }} @@ -22,6 +27,9 @@ Service ports mapped are: {{- if $useHostPort }} hostPort: {{ index $hostPorts $key | default $value }} {{- end }} + {{- if and (hasKey $nodePorts $key) (eq $servicePortType "NodePort") }} + nodePort: {{ get $nodePorts $key }} + {{- end }} {{- end }} {{- end }} diff --git a/haproxy/templates/service.yaml b/haproxy/templates/service.yaml index 776d2b9..dc0730d 100644 --- a/haproxy/templates/service.yaml +++ b/haproxy/templates/service.yaml @@ -50,6 +50,8 @@ spec: {{- toYaml . | nindent 2 }} {{- end }} {{- if or .Values.containerPorts .Values.service.additionalPorts }} + {{- $nodePorts := .Values.service.nodePorts }} + {{- $servicePortType := .Values.service.type }} ports: {{- with .Values.containerPorts }} {{- range $key, $port := . }} @@ -57,6 +59,9 @@ spec: protocol: TCP port: {{ $port }} targetPort: {{ $key }} + {{- if and (hasKey $nodePorts $key) (eq $servicePortType "NodePort") }} + nodePort: {{ get $nodePorts $key }} + {{- end }} {{- end }} {{- end }} {{- with .Values.service.additionalPorts }} @@ -65,6 +70,9 @@ spec: protocol: TCP port: {{ $port }} targetPort: {{ $key }} + {{- if and (hasKey $nodePorts $key) (eq $servicePortType "NodePort") }} + nodePort: {{ get $nodePorts $key }} + {{- end }} {{- end }} {{- end }} {{- end }} diff --git a/haproxy/values.yaml b/haproxy/values.yaml index 13adc4a..8014c72 100644 --- a/haproxy/values.yaml +++ b/haproxy/values.yaml @@ -449,7 +449,7 @@ PodDisruptionBudget: ## Service configuration ## ref: https://kubernetes.io/docs/concepts/services-networking/service/ service: - type: ClusterIP # can be 'LoadBalancer' + type: ClusterIP # can be 'ClusterIP', 'NodePort', 'LoadBalancer' ## Service ClusterIP ## ref: https://kubernetes.io/docs/concepts/services-networking/service/ @@ -484,6 +484,12 @@ service: additionalPorts: {} # prometheus: 9101 + ## NodePort custom port + ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#nodeport-custom-port + nodePorts: {} + # http: 32080 + # https: 32443 + serviceMonitor: ## Toggle the ServiceMonitor true if you have Prometheus Operator installed and configured enabled: false