This commit is contained in:
V
2025-12-06 23:12:48 +00:00
parent 3fdf119e94
commit dc4001f711
12 changed files with 22 additions and 8 deletions
@@ -0,0 +1,5 @@
creation_rules:
- path_regex: grafana-auth-secret.yaml$
encrypted_regex: "^(stringData)$"
age:
- age1u0mt3kmhsr9tz2jaw8n0ztu7s9hnlffkd2acxf85cvk6tysj4gsqqulfdq
@@ -0,0 +1,277 @@
kube-state-metrics:
# For kube-prometheus-stacks that are already installed and configured with
# custom collectors, commenting out the collectors and extraArgs below will
# retain any existing kube-state-metrics configuration.
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 Flux Kustomization 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: v2
kind: HelmRelease
metricNamePrefix: gotk
metrics:
- name: "resource_info"
help: "The current state of a Flux HelmRelease 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, history, "0", chartVersion ]
chart_name: [ status, history, "0", chartName ]
chart_app_version: [ status, history, "0", appVersion ]
chart_ref_name: [ spec, chartRef, name ]
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 Flux GitRepository 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 Flux Bucket 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: v1
kind: HelmRepository
metricNamePrefix: gotk
metrics:
- name: "resource_info"
help: "The current state of a Flux HelmRepository 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: v1
kind: HelmChart
metricNamePrefix: gotk
metrics:
- name: "resource_info"
help: "The current state of a Flux HelmChart 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 Flux OCIRepository 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 Flux Alert 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 Flux Provider 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 Flux Receiver 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 Flux ImageRepository 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 Flux ImagePolicy 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: v1beta2
kind: ImageUpdateAutomation
metricNamePrefix: gotk
metrics:
- name: "resource_info"
help: "The current state of a Flux ImageUpdateAutomation 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 ]
@@ -0,0 +1,12 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: monitoring
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
@@ -0,0 +1,23 @@
apiVersion: v1
kind: Secret
metadata:
name: flux-grafana-auth-secret
namespace: monitoring
type: Opaque
stringData:
values.yaml: ENC[AES256_GCM,data:RWxkOVXqeE+NZQ+0BrKPB4lrgNZ+hZVIz3/YkdOsu/HzDrPKjyaK,iv:bnC0wh+K9jT6X4VEC+Nb4zfuPPF/BFTqAOTFv0YUdTE=,tag:tWW0pBNPwY7yAOMTh+CIHg==,type:str]
sops:
age:
- recipient: age1u0mt3kmhsr9tz2jaw8n0ztu7s9hnlffkd2acxf85cvk6tysj4gsqqulfdq
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA2WElnVmpXL1JPVGdxSEox
WlJITU42eE9jQ3RuQ3RzR1J6ZXIxYjVGNFVzClRPNlNlalZZRTB3UTlkcnlNTVF3
ekh2Ym02SFlFNEJKS3VIaFJwZERtNVEKLS0tIERybExNMDZDK3AxM3ZUdi9XWFo5
clZ6MEIxbCtSZFBwckM0OTFxUE84S28KCMsNp5dtYQhH5J8/G04vzZu2ejNO4FoC
CS9dFSiN8zZ9lfUtwKkTHVR9QeYKtOXeFcpPMH7S8ebQ4apPHP/NUw==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2025-12-06T14:33:36Z"
mac: ENC[AES256_GCM,data:n2tiJq10ECYPeyptwawf1APEDXPm8pclxDZsej1xmsQ1KC/oG0M/WhhPzD2AIVJ23cKHgoV4m/6g7yt+WIAcTSREq4doHJbXExvjNY2yrVsVuM4Vq/ISM1GgPCHfMGFIzSQ9dTHpUmf7twVTsKfOehta9VAjamlts4l1kBctHK0=,iv:XPSkwFdF6vXAs5rlojt81TMkJBgy2gXOT5WnA0j74mw=,tag:KiJm+WDtRGxxiW4weAJ/Zg==,type:str]
encrypted_regex: ^(stringData)$
version: 3.11.0
@@ -0,0 +1,63 @@
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: prometheus-community
namespace: monitoring
spec:
interval: 12h
type: oci
url: oci://ghcr.io/prometheus-community/charts
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: kube-prometheus-stack
namespace: monitoring
spec:
serviceAccountName: flux
interval: 1h
chart:
spec:
version: 79.12.0 # {"$imagepolicy": "flux-system:kube-prometheus-stack:tag"}
chart: kube-prometheus-stack
sourceRef:
kind: HelmRepository
name: prometheus-community
interval: 12h
install:
crds: Create
timeout: 9m
upgrade:
crds: CreateReplace
timeout: 9m
driftDetection:
mode: enabled
ignore:
- paths:
- /metadata/annotations/prometheus-operator-validated
target:
kind: PrometheusRule
valuesFrom:
- kind: ConfigMap
name: flux-kube-state-metrics-config
valuesKey: kube-state-metrics-config.yaml
- kind: Secret
name: flux-grafana-auth-secret
valuesKey: values.yaml
values:
alertmanager:
enabled: false
prometheus:
prometheusSpec:
retention: 12h
resources:
requests:
cpu: 200m
memory: 200Mi
podMonitorNamespaceSelector: {}
podMonitorSelector:
matchLabels:
app.kubernetes.io/component: monitoring
grafana:
defaultDashboardsEnabled: false
replicas: 1
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
# Namespace is specified in each file in this case due to an issue with the RoleBinding
# namespace: monitoring
resources:
- grafana-auth-secret.yaml
- kube-prometheus-stack.yaml
- cm/
configurations:
- kustomizeconfig.yaml
@@ -0,0 +1,7 @@
nameReference:
- kind: ConfigMap
version: v1
fieldSpecs:
- path: spec/valuesFrom/name
kind: HelmRelease