Skip to content

Commit 991fe6d

Browse files
authored
BUG/MINOR: haproxy: Remove hardcode from configmap template for haproxy chart. (#233) (#234)
Signed-off-by: Mikhail Koniakhin <[email protected]>
1 parent dbf53cc commit 991fe6d

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

haproxy/templates/NOTES.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@ Controller image deployed is: "{{ .Values.image.repository }}:{{ tpl .Values.ima
55
Your HAProxy app is of a "{{ .Values.kind }}" kind.
66

77
Service ports mapped are:
8+
{{- $nodePorts := .Values.service.nodePorts }}
9+
{{- $servicePortType := .Values.service.type }}
810
{{- if eq .Values.kind "Deployment" }}
911
{{- range $key, $value := .Values.containerPorts }}
1012
- name: {{ $key }}
1113
containerPort: {{ $value }}
1214
protocol: TCP
15+
{{- if and (hasKey $nodePorts $key) (eq $servicePortType "NodePort") }}
16+
nodePort: {{ get $nodePorts $key }}
17+
{{- end }}
1318
{{- end }}
1419
{{- end }}
1520
{{- if eq .Values.kind "DaemonSet" }}
@@ -22,6 +27,9 @@ Service ports mapped are:
2227
{{- if $useHostPort }}
2328
hostPort: {{ index $hostPorts $key | default $value }}
2429
{{- end }}
30+
{{- if and (hasKey $nodePorts $key) (eq $servicePortType "NodePort") }}
31+
nodePort: {{ get $nodePorts $key }}
32+
{{- end }}
2533
{{- end }}
2634
{{- end }}
2735

haproxy/templates/service.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,18 @@ spec:
5050
{{- toYaml . | nindent 2 }}
5151
{{- end }}
5252
{{- if or .Values.containerPorts .Values.service.additionalPorts }}
53+
{{- $nodePorts := .Values.service.nodePorts }}
54+
{{- $servicePortType := .Values.service.type }}
5355
ports:
5456
{{- with .Values.containerPorts }}
5557
{{- range $key, $port := . }}
5658
- name: {{ $key }}
5759
protocol: TCP
5860
port: {{ $port }}
5961
targetPort: {{ $key }}
62+
{{- if and (hasKey $nodePorts $key) (eq $servicePortType "NodePort") }}
63+
nodePort: {{ get $nodePorts $key }}
64+
{{- end }}
6065
{{- end }}
6166
{{- end }}
6267
{{- with .Values.service.additionalPorts }}
@@ -65,6 +70,9 @@ spec:
6570
protocol: TCP
6671
port: {{ $port }}
6772
targetPort: {{ $key }}
73+
{{- if and (hasKey $nodePorts $key) (eq $servicePortType "NodePort") }}
74+
nodePort: {{ get $nodePorts $key }}
75+
{{- end }}
6876
{{- end }}
6977
{{- end }}
7078
{{- end }}

haproxy/values.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ PodDisruptionBudget:
449449
## Service configuration
450450
## ref: https://kubernetes.io/docs/concepts/services-networking/service/
451451
service:
452-
type: ClusterIP # can be 'LoadBalancer'
452+
type: ClusterIP # can be 'ClusterIP', 'NodePort', 'LoadBalancer'
453453

454454
## Service ClusterIP
455455
## ref: https://kubernetes.io/docs/concepts/services-networking/service/
@@ -484,6 +484,12 @@ service:
484484
additionalPorts: {}
485485
# prometheus: 9101
486486

487+
## NodePort custom port
488+
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#nodeport-custom-port
489+
nodePorts: {}
490+
# http: 32080
491+
# https: 32443
492+
487493
serviceMonitor:
488494
## Toggle the ServiceMonitor true if you have Prometheus Operator installed and configured
489495
enabled: false

0 commit comments

Comments
 (0)