Browse Source

Added HAproxy exporter

Change-Id: I99124d11639505c76bafcfe9be622135382e3f09
changes/84/742284/1
Mohammed Naser 2 years ago
parent
commit
7badbfad0b
  1. 11
      charts/haproxy-exporter/Chart.yaml
  2. 45
      charts/haproxy-exporter/templates/_helpers.tpl
  3. 47
      charts/haproxy-exporter/templates/daemonset.yaml
  4. 32
      charts/haproxy-exporter/templates/prometheusrule.yaml
  5. 16
      charts/haproxy-exporter/templates/service.yaml
  6. 23
      charts/haproxy-exporter/templates/servicemonitor.yaml
  7. 1
      charts/haproxy-exporter/values.yaml

11
charts/haproxy-exporter/Chart.yaml

@ -0,0 +1,11 @@
---
apiVersion: v1
name: haproxy-exporter
version: 0.3.1
description: HAProxy exporter for Prometheus
home: https://github.com/vexxhost/helm-charts
maintainers:
- name: Mohammed Naser
email: mnaser@vexxhost.com
url: https://github.com/mnaser
appVersion: v0.10.0

45
charts/haproxy-exporter/templates/_helpers.tpl

@ -0,0 +1,45 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "haproxy-exporter.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "haproxy-exporter.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Generate basic labels
*/}}
{{- define "haproxy-exporter.labels" }}
app.kubernetes.io/name: {{ include "haproxy-exporter.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: metrics
app.kubernetes.io/part-of: haproxy
{{- if .Values.commonLabels }}
{{ toYaml .Values.commonLabels }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "haproxy-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

47
charts/haproxy-exporter/templates/daemonset.yaml

@ -0,0 +1,47 @@
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
namespace: {{ .Release.Namespace }}
name: {{ include "haproxy-exporter.fullname" . }}
labels:
{{ include "haproxy-exporter.labels" $ | indent 4 }}
spec:
selector:
matchLabels:
{{ include "haproxy-exporter.labels" $ | indent 6 }}
template:
metadata:
labels:
{{ include "haproxy-exporter.labels" $ | indent 8 }}
spec:
containers:
- name: haproxy-exporter
image: prom/haproxy-exporter:v0.10.0
args:
- --haproxy.scrape-uri=unix:/var/run/haproxy.stat
resources:
limits:
cpu: 500m
memory: 180Mi
requests:
cpu: 250m
memory: 180Mi
volumeMounts:
- name: haproxy-socket
mountPath: /var/run/haproxy.stat
ports:
- name: metrics
containerPort: 9101
{{- with $.Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with $.Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
volumes:
- name: haproxy-socket
hostPath:
path: /var/run/haproxy.stat

32
charts/haproxy-exporter/templates/prometheusrule.yaml

@ -0,0 +1,32 @@
---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
namespace: {{ .Release.Namespace }}
name: {{ include "haproxy-exporter.fullname" . }}
labels:
{{ include "haproxy-exporter.labels" $ | indent 4 }}
spec:
groups:
- name: haproxy
rules:
- alert: HaproxyDown
expr: |
absent(haproxy_up == 1)
for: 1m
labels:
severity: critical
- alert: HaproxyBackendDown
for: 1m
expr: |
haproxy_backend_up != 1
labels:
severity: P2
- alert: HaproxyBackendDegraded
expr: |
avg(haproxy_server_up) by (instance, backend, server) != 1
for: 1m
labels:
severity: P3

16
charts/haproxy-exporter/templates/service.yaml

@ -0,0 +1,16 @@
---
apiVersion: v1
kind: Service
metadata:
namespace: {{ .Release.Namespace }}
name: {{ include "haproxy-exporter.fullname" . }}
labels:
{{ include "haproxy-exporter.labels" $ | indent 4 }}
spec:
clusterIP: None
ports:
- name: metrics
port: 9101
targetPort: metrics
selector:
{{ include "haproxy-exporter.labels" $ | indent 4 }}

23
charts/haproxy-exporter/templates/servicemonitor.yaml

@ -0,0 +1,23 @@
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
namespace: {{ .Release.Namespace }}
name: {{ include "haproxy-exporter.fullname" . }}
labels:
{{ include "haproxy-exporter.labels" $ | indent 4 }}
spec:
endpoints:
- interval: 30s
port: metrics
relabelings:
- action: replace
regex: (.*)
replacement: ${1}:9101
sourceLabels:
- __meta_kubernetes_pod_node_name
targetLabel: instance
jobLabel: jobLabel
selector:
matchLabels:
{{ include "haproxy-exporter.labels" $ | indent 6 }}

1
charts/haproxy-exporter/values.yaml

@ -0,0 +1 @@
---
Loading…
Cancel
Save