Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support NodePort service. #234

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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