Skip to content

Commit

Permalink
add option to use the haproxy's embedded metric exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmoraisjr committed Nov 1, 2020
1 parent 03c4c5e commit 8d13e41
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
6 changes: 4 additions & 2 deletions haproxy-ingress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ Parameter | Description | Default
`controller.stats.service.servicePort` | the port number exposed by the stats service | `1936`
`controller.stats.service.type` | type of controller service to create | `ClusterIP`
`controller.metrics.enabled` | If `controller.stats.enabled = true` and `controller.metrics.enabled = true`, Prometheus metrics will be exported | `false`
`controller.metrics.image.repository` | prometheus-exporter image repository | `quay.io/prometheus/haproxy-exporter`
`controller.metrics.embedded` | defines if embedded haproxy's exporter should be used | `true`
`controller.metrics.port` | port number the exporter is listening to | `9101`
`controller.metrics.image.repository` | prometheus-exporter image repository when embedded is `false` | `quay.io/prometheus/haproxy-exporter`
`controller.metrics.image.tag` | prometheus-exporter image tag | `v0.11.0`
`controller.metrics.image.pullPolicy` | prometheus-exporter image pullPolicy | `IfNotPresent`
`controller.metrics.extraArgs` | Extra arguments to the haproxy_exporter | `{}`
`controller.metrics.extraArgs` | Extra arguments to the prometheus-exporter | `{}`
`controller.metrics.resources` | prometheus-exporter container resource requests & limits | `{}`
`controller.metrics.service.annotations` | annotations for metrics service | `{}`
`controller.metrics.service.clusterIP` | internal metrics cluster service IP | `nil`
Expand Down
10 changes: 8 additions & 2 deletions haproxy-ingress/templates/_podtemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ spec:
hostPort: {{ .Values.controller.daemonset.hostPorts.https }}
{{- end }}
{{- end }}
{{- if and .Values.controller.metrics.enabled .Values.controller.metrics.embedded }}
- name: metrics
containerPort: {{ .Values.controller.metrics.port }}
protocol: TCP
{{- end }}
{{- if .Values.controller.stats.enabled }}
- name: stats
containerPort: {{ .Values.controller.stats.port }}
Expand Down Expand Up @@ -125,12 +130,13 @@ spec:
resources:
{{- toYaml .Values.controller.logs.resources | nindent 8 }}
{{- end }}
{{- if and .Values.controller.stats.enabled .Values.controller.metrics.enabled }}
{{- if and .Values.controller.stats.enabled .Values.controller.metrics.enabled (not .Values.controller.metrics.embedded) }}
- name: prometheus-exporter
image: "{{ .Values.controller.metrics.image.repository }}:{{ .Values.controller.metrics.image.tag }}"
imagePullPolicy: "{{ .Values.controller.metrics.image.pullPolicy }}"
args:
- '--haproxy.scrape-uri=http://localhost:{{ .Values.controller.stats.port }}/haproxy?stats;csv'
- --web.listen-address=:{{ .Values.controller.metrics.port }}
{{- range $key, $value := .Values.controller.metrics.extraArgs }}
{{- if $value }}
- --{{ $key }}={{ $value }}
Expand All @@ -140,7 +146,7 @@ spec:
{{- end }}
ports:
- name: metrics
containerPort: 9101
containerPort: {{ .Values.controller.metrics.port }}
protocol: TCP
livenessProbe:
httpGet:
Expand Down
3 changes: 3 additions & 0 deletions haproxy-ingress/templates/controller-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ metadata:
namespace: {{ .Release.Namespace }}
data:
healthz-port: {{ .Values.controller.healthzPort | quote }}
{{- if and .Values.controller.metrics.enabled .Values.controller.metrics.embedded }}
prometheus-port: {{ .Values.controller.metrics.port | quote }}
{{- end }}
stats-port: {{ .Values.controller.stats.port | quote }}
{{- if .Values.controller.logs.enabled }}
syslog-endpoint: "localhost:514"
Expand Down
2 changes: 1 addition & 1 deletion haproxy-ingress/templates/controller-metrics-service.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if and .Values.controller.stats.enabled .Values.controller.metrics.enabled -}}
{{- if and .Values.controller.metrics.enabled (or .Values.controller.stats.enabled .Values.controller.metrics.embedded) -}}
apiVersion: v1
kind: Service
metadata:
Expand Down
9 changes: 9 additions & 0 deletions haproxy-ingress/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,22 @@ controller:
type: ClusterIP

## If controller.stats.enabled = true and controller.metrics.enabled = true, Prometheus metrics will be exported
## Metrics will also be exposed if the embedded haproxy's exporter is used
##
metrics:
enabled: false

# Defines if the haproxy's embedded prometheus exporter should be used
# If false, haproxy_exporter sidecar container is used instead and stats need to be enabled
embedded: true

# Port number the exporter is listening to
port: 9101

# prometheus exporter for haproxy
# https://github.com/prometheus/haproxy_exporter
# (scrapes the stats port and exports metrics to prometheus)
# Only used if embedded == false
image:
repository: quay.io/prometheus/haproxy-exporter
tag: "v0.11.0"
Expand Down

0 comments on commit 8d13e41

Please sign in to comment.