From 419434df35d0d9d5466d45183dc58714ac37d375 Mon Sep 17 00:00:00 2001 From: Jazzlyn <9011011+jazzlyn@users.noreply.github.com> Date: Tue, 30 Jan 2024 21:36:25 +0100 Subject: [PATCH] feat(flux): add kube-state-metrics --- .../app/helm-release.yaml | 11 +- .../app/kube-state-metrics-values.yaml | 287 ++++++++++++++++++ .../app/kustomization.yaml | 3 + 3 files changed, 293 insertions(+), 8 deletions(-) create mode 100644 kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app/kube-state-metrics-values.yaml diff --git a/kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app/helm-release.yaml b/kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app/helm-release.yaml index 1bdd4c95f..de59c46c2 100644 --- a/kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app/helm-release.yaml +++ b/kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app/helm-release.yaml @@ -31,8 +31,11 @@ spec: valuesFrom: - kind: ConfigMap name: alertmanager-values + - kind: ConfigMap + name: kube-state-metrics-values - kind: ConfigMap name: prometheus-values + # https://artifacthub.io/packages/helm/prometheus-community/kube-prometheus-stack?modal=values values: cleanPrometheusOperatorObjectNames: true @@ -74,14 +77,6 @@ spec: - effect: "NoSchedule" operator: "Exists" - kube-state-metrics: - fullnameOverride: kube-state-metrics - selfMonitor: - enabled: true - prometheus: - monitor: - enabled: true - grafana: enabled: false forceDeployDashboards: true diff --git a/kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app/kube-state-metrics-values.yaml b/kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app/kube-state-metrics-values.yaml new file mode 100644 index 000000000..b78dbff45 --- /dev/null +++ b/kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app/kube-state-metrics-values.yaml @@ -0,0 +1,287 @@ +--- +kube-state-metrics: + fullnameOverride: kube-state-metrics + metricLabelsAllowlist: + - pods=[*] + - deployments=[*] + - persistentvolumeclaims=[*] + selfMonitor: + enabled: true + prometheus: + monitor: + enabled: true + relabelings: + - action: replace + regex: (.*) + replacement: $1 + sourceLabels: + - __meta_kubernetes_pod_node_name + targetLabel: kubernetes_node + rbac: + extraRules: + - apiGroups: + - source.toolkit.fluxcd.io + - kustomize.toolkit.fluxcd.io + - helm.toolkit.fluxcd.io + - notification.toolkit.fluxcd.io + - image.toolkit.fluxcd.io + resources: + - gitrepositories + - buckets + - helmrepositories + - helmcharts + - ocirepositories + - kustomizations + - helmreleases + - alerts + - providers + - receivers + - imagerepositories + - imagepolicies + - imageupdateautomations + verbs: ["list", "watch"] + customResourceState: + enabled: true + config: + spec: + resources: + - groupVersionKind: + group: kustomize.toolkit.fluxcd.io + version: v1 + kind: Kustomization + metricNamePrefix: gotk + metrics: + - name: "resource_info" + help: "The current state of a GitOps Toolkit resource." + each: + type: Info + info: + labelsFromPath: + name: [metadata, name] + labelsFromPath: + exported_namespace: [metadata, namespace] + ready: [status, conditions, "[type=Ready]", status] + suspended: [spec, suspend] + revision: [status, lastAppliedRevision] + source_name: [spec, sourceRef, name] + - groupVersionKind: + group: helm.toolkit.fluxcd.io + version: v2beta2 + kind: HelmRelease + metricNamePrefix: gotk + metrics: + - name: "resource_info" + help: "The current state of a GitOps Toolkit resource." + each: + type: Info + info: + labelsFromPath: + name: [metadata, name] + labelsFromPath: + exported_namespace: [metadata, namespace] + ready: [status, conditions, "[type=Ready]", status] + suspended: [spec, suspend] + revision: [status, lastAppliedRevision] + chart_name: [spec, chart, spec, chart] + chart_source_name: [spec, chart, spec, sourceRef, name] + - groupVersionKind: + group: source.toolkit.fluxcd.io + version: v1 + kind: GitRepository + metricNamePrefix: gotk + metrics: + - name: "resource_info" + help: "The current state of a GitOps Toolkit resource." + each: + type: Info + info: + labelsFromPath: + name: [metadata, name] + labelsFromPath: + exported_namespace: [metadata, namespace] + ready: [status, conditions, "[type=Ready]", status] + suspended: [spec, suspend] + revision: [status, artifact, revision] + url: [spec, url] + - groupVersionKind: + group: source.toolkit.fluxcd.io + version: v1beta2 + kind: Bucket + metricNamePrefix: gotk + metrics: + - name: "resource_info" + help: "The current state of a GitOps Toolkit resource." + each: + type: Info + info: + labelsFromPath: + name: [metadata, name] + labelsFromPath: + exported_namespace: [metadata, namespace] + ready: [status, conditions, "[type=Ready]", status] + suspended: [spec, suspend] + revision: [status, artifact, revision] + endpoint: [spec, endpoint] + bucket_name: [spec, bucketName] + - groupVersionKind: + group: source.toolkit.fluxcd.io + version: v1beta2 + kind: HelmRepository + metricNamePrefix: gotk + metrics: + - name: "resource_info" + help: "The current state of a GitOps Toolkit resource." + each: + type: Info + info: + labelsFromPath: + name: [metadata, name] + labelsFromPath: + exported_namespace: [metadata, namespace] + ready: [status, conditions, "[type=Ready]", status] + suspended: [spec, suspend] + revision: [status, artifact, revision] + url: [spec, url] + - groupVersionKind: + group: source.toolkit.fluxcd.io + version: v1beta2 + kind: HelmChart + metricNamePrefix: gotk + metrics: + - name: "resource_info" + help: "The current state of a GitOps Toolkit resource." + each: + type: Info + info: + labelsFromPath: + name: [metadata, name] + labelsFromPath: + exported_namespace: [metadata, namespace] + ready: [status, conditions, "[type=Ready]", status] + suspended: [spec, suspend] + revision: [status, artifact, revision] + chart_name: [spec, chart] + chart_version: [spec, version] + - groupVersionKind: + group: source.toolkit.fluxcd.io + version: v1beta2 + kind: OCIRepository + metricNamePrefix: gotk + metrics: + - name: "resource_info" + help: "The current state of a GitOps Toolkit resource." + each: + type: Info + info: + labelsFromPath: + name: [metadata, name] + labelsFromPath: + exported_namespace: [metadata, namespace] + ready: [status, conditions, "[type=Ready]", status] + suspended: [spec, suspend] + revision: [status, artifact, revision] + url: [spec, url] + - groupVersionKind: + group: notification.toolkit.fluxcd.io + version: v1beta3 + kind: Alert + metricNamePrefix: gotk + metrics: + - name: "resource_info" + help: "The current state of a GitOps Toolkit resource." + each: + type: Info + info: + labelsFromPath: + name: [metadata, name] + labelsFromPath: + exported_namespace: [metadata, namespace] + suspended: [spec, suspend] + - groupVersionKind: + group: notification.toolkit.fluxcd.io + version: v1beta3 + kind: Provider + metricNamePrefix: gotk + metrics: + - name: "resource_info" + help: "The current state of a GitOps Toolkit resource." + each: + type: Info + info: + labelsFromPath: + name: [metadata, name] + labelsFromPath: + exported_namespace: [metadata, namespace] + suspended: [spec, suspend] + - groupVersionKind: + group: notification.toolkit.fluxcd.io + version: v1 + kind: Receiver + metricNamePrefix: gotk + metrics: + - name: "resource_info" + help: "The current state of a GitOps Toolkit resource." + each: + type: Info + info: + labelsFromPath: + name: [metadata, name] + labelsFromPath: + exported_namespace: [metadata, namespace] + ready: [status, conditions, "[type=Ready]", status] + suspended: [spec, suspend] + webhook_path: [status, webhookPath] + - groupVersionKind: + group: image.toolkit.fluxcd.io + version: v1beta2 + kind: ImageRepository + metricNamePrefix: gotk + metrics: + - name: "resource_info" + help: "The current state of a GitOps Toolkit resource." + each: + type: Info + info: + labelsFromPath: + name: [metadata, name] + labelsFromPath: + exported_namespace: [metadata, namespace] + ready: [status, conditions, "[type=Ready]", status] + suspended: [spec, suspend] + image: [spec, image] + - groupVersionKind: + group: image.toolkit.fluxcd.io + version: v1beta2 + kind: ImagePolicy + metricNamePrefix: gotk + metrics: + - name: "resource_info" + help: "The current state of a GitOps Toolkit resource." + each: + type: Info + info: + labelsFromPath: + name: [metadata, name] + labelsFromPath: + exported_namespace: [metadata, namespace] + ready: [status, conditions, "[type=Ready]", status] + suspended: [spec, suspend] + source_name: [spec, imageRepositoryRef, name] + - groupVersionKind: + group: image.toolkit.fluxcd.io + version: v1beta1 + kind: ImageUpdateAutomation + metricNamePrefix: gotk + metrics: + - name: "resource_info" + help: "The current state of a GitOps Toolkit resource." + each: + type: Info + info: + labelsFromPath: + name: [metadata, name] + labelsFromPath: + exported_namespace: [metadata, namespace] + ready: [status, conditions, "[type=Ready]", status] + suspended: [spec, suspend] + source_name: [spec, sourceRef, name] diff --git a/kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app/kustomization.yaml b/kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app/kustomization.yaml index 46e9a3f5a..96c70add1 100644 --- a/kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app/kustomization.yaml +++ b/kubernetes/talos-flux/apps/observability/kube-prometheus-stack/app/kustomization.yaml @@ -12,6 +12,9 @@ configMapGenerator: - name: alertmanager-values files: - values.yaml=alertmanager-values.yaml + - name: kube-state-metrics-values + files: + - values.yaml=kube-state-metrics-values.yaml - name: prometheus-values files: - values.yaml=prometheus-values.yaml