Skip to content

Commit

Permalink
Add support NodePort service.
Browse files Browse the repository at this point in the history
  • Loading branch information
MemberIT committed Apr 3, 2024
1 parent af3c9d2 commit 1be5930
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
6 changes: 2 additions & 4 deletions haproxy/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
8 changes: 8 additions & 0 deletions haproxy/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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" }}
Expand All @@ -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 }}

Expand Down
8 changes: 8 additions & 0 deletions haproxy/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,18 @@ 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 := . }}
- name: {{ $key }}
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 }}
Expand All @@ -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 }}
8 changes: 7 additions & 1 deletion haproxy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1be5930

Please sign in to comment.