From 84495a1d95b17154a0bf975c6b97c4cecdd36666 Mon Sep 17 00:00:00 2001 From: kongfei Date: Fri, 1 Jul 2022 17:34:37 +0800 Subject: [PATCH 1/3] collect kubelet metrics with daemonset --- k8s/daemonset.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/k8s/daemonset.yaml b/k8s/daemonset.yaml index a28da293..a0b7b8e2 100644 --- a/k8s/daemonset.yaml +++ b/k8s/daemonset.yaml @@ -299,6 +299,26 @@ data: insecure_skip_verify = true --- kind: ConfigMap +metadata: + name: input-kubelete-metrics +apiVersion: v1 +data: + prometheus.toml: | + # # collect interval + # interval = 15 + + [[instances]] + # kubelete metrics & cadvisor + urls = ["https://127.0.0.1:10250/metrics", "https://127.0.0.1:10250/metrics/cadvisor"] + bearer_token_file = "/var/run/secrets/kubernetes.io/serviceaccount/token" + use_tls = true + insecure_skip_verify = true + url_label_key = "instance" + url_label_value = "{{.Host}}" + # if you use dashboards, do not delete this label + labels = {job="categraf"} +--- +kind: ConfigMap metadata: name: input-kernel apiVersion: v1 @@ -583,6 +603,8 @@ spec: name: input-docker - mountPath: /etc/categraf/conf/input.kubernetes name: input-kubernetes + - mountPath: /etc/categraf/conf/input.prometheus + name: input-kubelet-metrics - mountPath: /etc/categraf/conf/input.kernel name: input-kernel - mountPath: /etc/categraf/conf/input.kernel_vmstat @@ -646,6 +668,10 @@ spec: defaultMode: 420 name: input-kubernetes name: input-kubernetes + - configMap: + defaultMode: 420 + name: input-kubelete-metrics + name: input-kubelet-mertrics - configMap: defaultMode: 420 name: input-kernel From 2c9f85c206203a6a89e6240750e23f28e1a59530 Mon Sep 17 00:00:00 2001 From: kongfei Date: Mon, 4 Jul 2022 11:49:48 +0800 Subject: [PATCH 2/3] delete nonresource metrics auth from daemonset --- k8s/daemonset.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/k8s/daemonset.yaml b/k8s/daemonset.yaml index a0b7b8e2..7292a6b4 100644 --- a/k8s/daemonset.yaml +++ b/k8s/daemonset.yaml @@ -17,10 +17,6 @@ rules: - nodes/proxy verbs: - get -- nonResourceURLs: - - /metrics - verbs: - - get --- apiVersion: v1 kind: ServiceAccount From 74cda6762e7818c7a0184c61d29fe2af0b6b3898 Mon Sep 17 00:00:00 2001 From: kongfei Date: Mon, 4 Jul 2022 18:20:48 +0800 Subject: [PATCH 3/3] fix typo --- k8s/daemonset.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/k8s/daemonset.yaml b/k8s/daemonset.yaml index 7292a6b4..090bec51 100644 --- a/k8s/daemonset.yaml +++ b/k8s/daemonset.yaml @@ -296,7 +296,7 @@ data: --- kind: ConfigMap metadata: - name: input-kubelete-metrics + name: input-kubelet-metrics apiVersion: v1 data: prometheus.toml: | @@ -666,7 +666,7 @@ spec: name: input-kubernetes - configMap: defaultMode: 420 - name: input-kubelete-metrics + name: input-kubelet-metrics name: input-kubelet-mertrics - configMap: defaultMode: 420