From 3b91e14f6dff0fad024ae44a58b40f76e677bd1c Mon Sep 17 00:00:00 2001 From: Somtochi Onyekwere Date: Fri, 7 May 2021 12:02:39 +0100 Subject: [PATCH] Use kube-prometheus-stack for monitoring Signed-off-by: Somtochi Onyekwere --- .../grafana/dashboards/cluster.json | 20 ++++++++++----- .../grafana/dashboards/control-plane.json | 6 ++--- .../kube-prometheus-stack/kustomization.yaml | 7 ++++++ .../kube-prometheus-stack/namespace.yaml | 4 +++ .../kube-prometheus-stack/release.yaml | 25 +++++++++++++++++++ .../kube-prometheus-stack/repository.yaml | 7 ++++++ .../monitoring-config/kustomization.yaml | 13 ++++++++++ .../monitoring-config/podmonitor.yaml | 24 ++++++++++++++++++ 8 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 manifests/monitoring/kube-prometheus-stack/kustomization.yaml create mode 100644 manifests/monitoring/kube-prometheus-stack/namespace.yaml create mode 100644 manifests/monitoring/kube-prometheus-stack/release.yaml create mode 100644 manifests/monitoring/kube-prometheus-stack/repository.yaml create mode 100644 manifests/monitoring/monitoring-config/kustomization.yaml create mode 100644 manifests/monitoring/monitoring-config/podmonitor.yaml diff --git a/manifests/monitoring/grafana/dashboards/cluster.json b/manifests/monitoring/grafana/dashboards/cluster.json index 871a7c99..c0677d2b 100644 --- a/manifests/monitoring/grafana/dashboards/cluster.json +++ b/manifests/monitoring/grafana/dashboards/cluster.json @@ -482,16 +482,20 @@ "job": true, "kubernetes_namespace": true, "kubernetes_pod_name": true, - "namespace": true, "pod_template_hash": true, "status": true, - "type": true + "type": true, + "pod": true, + "container": true, + "endpoint": true, + "exported_namespace": true }, "indexByName": {}, "renameByName": { "Value": "Status", "kind": "Kind", - "name": "Name" + "name": "Name", + "namespace": "Namespace" } } } @@ -594,15 +598,19 @@ "job": true, "kubernetes_namespace": true, "kubernetes_pod_name": true, - "namespace": true, "pod_template_hash": true, + "pod": true, "status": true, - "type": true + "type": true, + "container": true, + "endpoint": true, + "exported_namespace": true }, "indexByName": {}, "renameByName": { "Value": "Status", "kind": "Kind", + "namespace": "Namespace", "name": "Name" } } @@ -831,7 +839,7 @@ "schemaVersion": 26, "style": "light", "tags": [ - "gitops-toolkit" + "flux" ], "templating": { "list": [ diff --git a/manifests/monitoring/grafana/dashboards/control-plane.json b/manifests/monitoring/grafana/dashboards/control-plane.json index 463ca7e1..38ae3a0a 100644 --- a/manifests/monitoring/grafana/dashboards/control-plane.json +++ b/manifests/monitoring/grafana/dashboards/control-plane.json @@ -1356,7 +1356,7 @@ "schemaVersion": 26, "style": "light", "tags": [ - "gitops-toolkit" + "flux" ], "templating": { "list": [ @@ -1424,7 +1424,7 @@ ] }, "timezone": "", - "title": "GitOps Toolkit Control Plane", - "uid": "gitops-toolkit-control-plane", + "title": "Flux Control Plane", + "uid": "flux-control-plane", "version": 1 } diff --git a/manifests/monitoring/kube-prometheus-stack/kustomization.yaml b/manifests/monitoring/kube-prometheus-stack/kustomization.yaml new file mode 100644 index 00000000..920eff14 --- /dev/null +++ b/manifests/monitoring/kube-prometheus-stack/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: monitoring +resources: + - namespace.yaml + - repository.yaml + - release.yaml diff --git a/manifests/monitoring/kube-prometheus-stack/namespace.yaml b/manifests/monitoring/kube-prometheus-stack/namespace.yaml new file mode 100644 index 00000000..d3252360 --- /dev/null +++ b/manifests/monitoring/kube-prometheus-stack/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: monitoring diff --git a/manifests/monitoring/kube-prometheus-stack/release.yaml b/manifests/monitoring/kube-prometheus-stack/release.yaml new file mode 100644 index 00000000..f4061f65 --- /dev/null +++ b/manifests/monitoring/kube-prometheus-stack/release.yaml @@ -0,0 +1,25 @@ +apiVersion: helm.toolkit.fluxcd.io/v2beta1 +kind: HelmRelease +metadata: + name: kube-prometheus-stack +spec: + interval: 5m + chart: + spec: + chart: kube-prometheus-stack + sourceRef: + kind: HelmRepository + name: prometheus-community + interval: 1m + values: + alertmanager: + enabled: false + grafana: + sidecar: + dashboards: + searchNamespace: ALL + prometheus: + prometheusSpec: + podMonitorSelector: + matchLabels: + app.kubernetes.io/part-of: flux diff --git a/manifests/monitoring/kube-prometheus-stack/repository.yaml b/manifests/monitoring/kube-prometheus-stack/repository.yaml new file mode 100644 index 00000000..258f4087 --- /dev/null +++ b/manifests/monitoring/kube-prometheus-stack/repository.yaml @@ -0,0 +1,7 @@ +apiVersion: source.toolkit.fluxcd.io/v1beta1 +kind: HelmRepository +metadata: + name: prometheus-community +spec: + interval: 1m + url: https://prometheus-community.github.io/helm-charts diff --git a/manifests/monitoring/monitoring-config/kustomization.yaml b/manifests/monitoring/monitoring-config/kustomization.yaml new file mode 100644 index 00000000..7b53fa1f --- /dev/null +++ b/manifests/monitoring/monitoring-config/kustomization.yaml @@ -0,0 +1,13 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: flux-system +resources: + - podmonitor.yaml +configMapGenerator: + - name: flux-grafana-dashboards + files: + - ../grafana/dashboards/control-plane.json + - ../grafana/dashboards/cluster.json + options: + labels: + grafana_dashboard: flux-system diff --git a/manifests/monitoring/monitoring-config/podmonitor.yaml b/manifests/monitoring/monitoring-config/podmonitor.yaml new file mode 100644 index 00000000..2f72d47e --- /dev/null +++ b/manifests/monitoring/monitoring-config/podmonitor.yaml @@ -0,0 +1,24 @@ +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: flux-system + namespace: flux-system + labels: + app.kubernetes.io/part-of: flux +spec: + namespaceSelector: + matchNames: + - flux-system + selector: + matchExpressions: + - key: app + operator: In + values: + - helm-controller + - source-controller + - kustomize-controller + - notification-controller + - image-automation-controller + - image-reflector-controller + podMetricsEndpoints: + - targetPort: http-prom