Skip to content

Commit

Permalink
Merge pull request #236 from sighupio/feature-haproxy-monitoring
Browse files Browse the repository at this point in the history
feature(onprem): enable haproxy monitoring
  • Loading branch information
nutellinoit authored Jul 31, 2024
2 parents 9387770 + 073eebb commit 5bb6fc0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ resources:
- {{ print "../" .spec.distribution.common.relativeVendorPath "/modules/monitoring/katalog/blackbox-exporter" }}
{{- if eq .spec.distribution.common.provider.type "none" }}{{/* none === on-premises */}}
- {{ print "../" .spec.distribution.common.relativeVendorPath "/modules/monitoring/katalog/kubeadm-sm" }}
{{- if .spec.kubernetes.loadBalancers.enabled }}
- {{ print "../" .spec.distribution.common.relativeVendorPath "/modules/monitoring/katalog/haproxy" }}
- resources/haproxy-scrapeConfig.yaml
{{- end }}
{{- end }}
{{- if eq .spec.distribution.common.provider.type "eks" }}
- {{ print "../" .spec.distribution.common.relativeVendorPath "/modules/monitoring/katalog/eks-sm" }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if and (eq .spec.distribution.common.provider.type "none") .spec.kubernetes.loadBalancers.enabled }}
---
apiVersion: monitoring.coreos.com/v1alpha1
kind: ScrapeConfig
metadata:
name: haproxy-lb
namespace: monitoring
labels:
prometheus: k8s
spec:
staticConfigs:
- labels:
job: prometheus
targets:
{{- range $lb := .spec.kubernetes.loadBalancers.hosts }}
- {{ $lb.ip }}:8405
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ spec:
probeSelector: {}
serviceMonitorNamespaceSelector: {}
serviceMonitorSelector: {}
scrapeConfigSelector:
matchLabels:
prometheus: k8s

{{- $prometheusAgentArgs := dict "module" "monitoring" "package" "prometheusAgent" "spec" .spec }}
tolerations:
Expand Down
3 changes: 3 additions & 0 deletions templates/distribution/scripts/pre-apply.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ deleteMonitoringCommon() {
$kustomizebin build $vendorPath/modules/monitoring/katalog/kube-state-metrics | $kubectlbin delete --ignore-not-found --wait --timeout=180s -f -
$kustomizebin build $vendorPath/modules/monitoring/katalog/node-exporter | $kubectlbin delete --ignore-not-found --wait --timeout=180s -f -
$kustomizebin build $vendorPath/modules/monitoring/katalog/x509-exporter | $kubectlbin delete --ignore-not-found --wait --timeout=180s -f -
{{- if and (eq .spec.distribution.common.provider.type "none") .spec.kubernetes.loadBalancers.enabled }}
$kustomizebin build $vendorPath/modules/monitoring/katalog/haproxy | $kubectlbin delete --ignore-not-found --wait --timeout=180s -f -
{{- end }}
echo "Monitoring common resources deleted."
}

Expand Down
11 changes: 7 additions & 4 deletions templates/kubernetes/onpremises/haproxy.cfg.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ defaults
timeout client 50s
timeout server 50s

listen stats
frontend stats
bind *:1936
mode http
log global

maxconn 10

timeout client 100s
timeout server 100s
timeout connect 100s
timeout queue 100s

stats enable
stats uri /stats
Expand All @@ -30,6 +27,12 @@ listen stats
stats show-node
stats auth {{ .spec.kubernetes.loadBalancers.stats.username }}:{{ .spec.kubernetes.loadBalancers.stats.password }}

frontend prometheus
bind :8405
mode http
http-request use-service prometheus-exporter
no log

frontend control-plane
mode tcp
bind *:6443 alpn h2,http/1.1
Expand Down

0 comments on commit 5bb6fc0

Please sign in to comment.