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

chore(haproxy): streamline service port configuration for flexibility #228

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions haproxy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,26 @@ Encode an imagePullSecret string.
{{- end }}

{{/* vim: set filetype=mustache: */}}

{{/*
Exposed ports to service
*/}}
{{- define "haproxy.exposedPorts" }}
{{- $exposedPorts := .Values.service.exposedPorts }}
{{- if empty $exposedPorts }}
{{- $containerPorts := .Values.containerPorts }}
{{- range $key, $port := $containerPorts }}
- name: {{ $key }}
protocol: TCP
port: {{ $port }}
targetPort: {{ $key }}
{{- end }}
{{- else }}
{{- range $key, $port := $exposedPorts }}
- name: {{ $key }}
protocol: TCP
port: {{ $port }}
targetPort: {{ $key }}
{{- end }}
{{- end }}
{{- end }}
9 changes: 1 addition & 8 deletions haproxy/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,7 @@ spec:
{{- end }}
{{- if or .Values.containerPorts .Values.service.additionalPorts }}
ports:
{{- with .Values.containerPorts }}
{{- range $key, $port := . }}
- name: {{ $key }}
protocol: TCP
port: {{ $port }}
targetPort: {{ $key }}
{{- end }}
{{- end }}
{{- include "haproxy.exposedPorts" . | nindent 3 -}}
{{- with .Values.service.additionalPorts }}
{{- range $key, $port := . }}
- name: {{ $key }}
Expand Down
6 changes: 6 additions & 0 deletions haproxy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,12 @@ service:
additionalPorts: {}
# prometheus: 9101

## Deterministic exposure of ports to the service
## .Values.containerPorts will be exposed if exposedPorts is empty
## ref: https://kubernetes.io/docs/concepts/services-networking/service/
exposedPorts: {}
# http: 80

serviceMonitor:
## Toggle the ServiceMonitor true if you have Prometheus Operator installed and configured
enabled: false
Expand Down