diff --git a/monitoring/controllers/kube-prometheus-stack/kube-state-metrics-config.yaml b/monitoring/controllers/kube-prometheus-stack/kube-state-metrics-config.yaml new file mode 100644 index 0000000..bd216a0 --- /dev/null +++ b/monitoring/controllers/kube-prometheus-stack/kube-state-metrics-config.yaml @@ -0,0 +1,274 @@ +kube-state-metrics: + collectors: [ ] + extraArgs: + - --custom-resource-state-only=true + 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: v2beta1 + 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: v1beta2 + 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 ] + ready: [ status, conditions, "[type=Ready]", status ] + suspended: [ spec, suspend ] + - groupVersionKind: + group: notification.toolkit.fluxcd.io + version: v1beta2 + 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 ] + ready: [ status, conditions, "[type=Ready]", status ] + 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/monitoring/controllers/kube-prometheus-stack/kustomization.yaml b/monitoring/controllers/kube-prometheus-stack/kustomization.yaml index 920eff1..d39eb9f 100644 --- a/monitoring/controllers/kube-prometheus-stack/kustomization.yaml +++ b/monitoring/controllers/kube-prometheus-stack/kustomization.yaml @@ -5,3 +5,13 @@ resources: - namespace.yaml - repository.yaml - release.yaml +configMapGenerator: + - name: flux-kube-state-metrics-config + files: + - kube-state-metrics-config.yaml + options: + labels: + app.kubernetes.io/part-of: flux + app.kubernetes.io/component: monitoring +configurations: + - kustomizeconfig.yaml diff --git a/monitoring/controllers/kube-prometheus-stack/kustomizeconfig.yaml b/monitoring/controllers/kube-prometheus-stack/kustomizeconfig.yaml new file mode 100644 index 0000000..7c31b22 --- /dev/null +++ b/monitoring/controllers/kube-prometheus-stack/kustomizeconfig.yaml @@ -0,0 +1,6 @@ +nameReference: +- kind: ConfigMap + version: v1 + fieldSpecs: + - path: spec/valuesFrom/name + kind: HelmRelease diff --git a/monitoring/controllers/kube-prometheus-stack/release.yaml b/monitoring/controllers/kube-prometheus-stack/release.yaml index ebef9b6..f1a848e 100644 --- a/monitoring/controllers/kube-prometheus-stack/release.yaml +++ b/monitoring/controllers/kube-prometheus-stack/release.yaml @@ -16,6 +16,10 @@ spec: crds: Create upgrade: crds: CreateReplace + valuesFrom: + - kind: ConfigMap + name: flux-kube-state-metrics-config + valuesKey: kube-state-metrics-config.yaml # https://github.com/prometheus-community/helm-charts/blob/main/charts/kube-prometheus-stack/values.yaml values: alertmanager: @@ -34,280 +38,6 @@ spec: grafana: defaultDashboardsEnabled: false adminPassword: flux - kube-state-metrics: - collectors: [ ] - extraArgs: - - --custom-resource-state-only=true - 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: v2beta1 - 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: v1beta2 - 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 ] - ready: [ status, conditions, "[type=Ready]", status ] - suspended: [ spec, suspend ] - - groupVersionKind: - group: notification.toolkit.fluxcd.io - version: v1beta2 - 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 ] - ready: [ status, conditions, "[type=Ready]", status ] - 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 ] postRenderers: - kustomize: patches: