Adopt Folly Prometheus Operator CRDs
Use this to wire folly onto the
monitoring-crdsKustomization the same way Runbooks/Kubernetes GitOps Change's GitOps rule normally requires β except the first step is a live, by-hand mutation. That is deliberate: see "The one sanctioned exception" below before running anything here.Why folly needs this
Offsite installs the Prometheus Operator CRDs from a dedicated
monitoring-crdsKustomization that itsmonitoringKustomizationdependsOn, fixing a Flux bootstrap deadlock:clusters/base/monitoring/carries a rawServiceMonitor, Flux server-side dry-runs every object in a Kustomization before applying any of them, and without the CRD already on the cluster the wholemonitoringKustomization was refused β including thekube-prometheus-stackHelmRelease that would have supplied the CRD (fixed for offsite in #1788). Seeclusters/base/monitoring-crds/andclusters/offsite/flux-system/monitoring-crds.yaml.Folly is not wired to
monitoring-crdsyet, and has the same latent deadlock on a from-scratch rebuild. It is not wired becausekube-prometheus-stackships its CRDs in a Helmcrds/directory, which Helm installs without ownership metadata and never upgrades. Folly's existing CRDs β installed years ago through that path β carry noapp.kubernetes.io/managed-by: Helmlabel and nometa.helm.sh/release-*annotations. Pointing folly'smonitoring-crdsKustomization at the templates-basedprometheus-operator-crdschart without first labeling those CRDs makes the chart try to create resources that already exist, and Helm refuses with "invalid ownership metadata" β the install fails, andmonitoringstays blocked behind a Kustomization that never reaches Ready. Same deadlock shape, different trigger.Adopting the ten existing CRDs into the chart's ownership is what breaks that, permanently, without a delete-and-recreate that would drop every
ServiceMonitor,PrometheusRule, and friend in the cluster along with the CRD.
The one sanctioned exception
The repo's hard rule is: never mutate live infrastructure by hand, author desired state in git and let the operators apply it. This procedure's first step breaks that rule on purpose, because Helm's adoption metadata β the label and two annotations below β has no git-side representation. Nothing in
clusters/can set them; they only exist as live object state. Stamping them by hand is the only way to make an existing, unmanaged CRD adoptable by a chart.Run the stamp deliberately, by an operator, once. It is not a step Flux or any controller performs, and there is no automation for it in this repo.
Stamp ownership metadata onto folly's CRDs (live, one-time)
The ten CRDs
kube-prometheus-stackcurrently owns unmanaged on folly:alertmanagerconfigs.monitoring.coreos.com alertmanagers.monitoring.coreos.com podmonitors.monitoring.coreos.com probes.monitoring.coreos.com prometheusagents.monitoring.coreos.com prometheuses.monitoring.coreos.com prometheusrules.monitoring.coreos.com scrapeconfigs.monitoring.coreos.com servicemonitors.monitoring.coreos.com thanosrulers.monitoring.coreos.comConfirm they are actually unmanaged before touching anything β this should print nothing for each:
for crd in alertmanagerconfigs.monitoring.coreos.com alertmanagers.monitoring.coreos.com \ podmonitors.monitoring.coreos.com probes.monitoring.coreos.com \ prometheusagents.monitoring.coreos.com prometheuses.monitoring.coreos.com \ prometheusrules.monitoring.coreos.com scrapeconfigs.monitoring.coreos.com \ servicemonitors.monitoring.coreos.com thanosrulers.monitoring.coreos.com; do kubectl --context folly get crd "$crd" \ -o jsonpath='{.metadata.labels.app\.kubernetes\.io/managed-by}{"\n"}' doneThe three markers Helm's adoption check requires, applied to each CRD:
label
app.kubernetes.io/managed-by=Helmannotation
meta.helm.sh/release-name=prometheus-operator-crdsannotation
meta.helm.sh/release-namespace=flux-systemβflux-system, notmonitoring, because what the chart installs is cluster-scoped and themonitoringnamespace is created by the Kustomization that runs after this one. Offsite uses the same namespace for the same reason; seeclusters/base/monitoring-crds/prometheus-operator-crds.yaml.
Apply all three to all ten CRDs:
CRDS=( alertmanagerconfigs.monitoring.coreos.com alertmanagers.monitoring.coreos.com podmonitors.monitoring.coreos.com probes.monitoring.coreos.com prometheusagents.monitoring.coreos.com prometheuses.monitoring.coreos.com prometheusrules.monitoring.coreos.com scrapeconfigs.monitoring.coreos.com servicemonitors.monitoring.coreos.com thanosrulers.monitoring.coreos.com ) for crd in "${CRDS[@]}"; do kubectl --context folly label crd "$crd" app.kubernetes.io/managed-by=Helm --overwrite kubectl --context folly annotate crd "$crd" \ meta.helm.sh/release-name=prometheus-operator-crds \ meta.helm.sh/release-namespace=flux-system --overwrite doneVerify every CRD carries all three markers:
for crd in "${CRDS[@]}"; do kubectl --context folly get crd "$crd" -o jsonpath=\ '{.metadata.name} managed-by={.metadata.labels.app\.kubernetes\.io/managed-by} release={.metadata.annotations.meta\.helm\.sh/release-name} ns={.metadata.annotations.meta\.helm\.sh/release-namespace}{"\n"}' doneEach line should read
managed-by=Helm release=prometheus-operator-crds ns=flux-system. Do not continue to the git-side change until all ten do.
Wire folly into monitoring-crds (git, only after the stamp succeeds)
Mirror
clusters/offsite/exactly. Five changes:Add a new clusters/folly/monitoring-crds/ directory:
clusters/folly/monitoring-crds/kustomization.yaml--- apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - ../../base/monitoring-crdsAdd a new Flux Kustomization at:
clusters/folly/flux-system/monitoring-crds.yaml--- apiVersion: kustomize.toolkit.fluxcd.io/v1 kind: Kustomization metadata: name: monitoring-crds namespace: flux-system spec: interval: 1h0m0s path: ./clusters/folly/monitoring-crds prune: true sourceRef: kind: GitRepository name: infraList it in
clusters/folly/flux-system/kustomization.yaml'sresources, the wayclusters/offsite/flux-system/kustomization.yamllistsmonitoring-crds.yaml.Add
monitoring-crdsto thedependsOninclusters/folly/flux-system/monitoring.yaml, alongside the existingstorageentry β matching thedependsOnshape already inclusters/offsite/flux-system/monitoring.yaml.Set
crds.enabledtofalseundervalues:inclusters/folly/monitoring/kube-prometheus.yaml, matchingclusters/offsite/monitoring/kube-prometheus.yaml. Leaving ittruemakes the chart try to install CRDs it now owns by adoption rather than by its owncrds/directory, on every upgrade β harmless once adopted, but redundant with themonitoring-crdsKustomization this wiring adds.
Order matters
The stamp must land on the live cluster before the git-side change merges. If the Kustomization and
dependsOnwiring merge first, Flux installs theprometheus-operator-crdsHelmRelease against CRDs that still lack ownership metadata, the install fails with "invalid ownership metadata", andmonitoringstays blocked behind a Kustomization that never reaches Ready β the exact deadlock this procedure exists to avoid, now self-inflicted by wiring ahead of the stamp.
Verify after merge
flux --context folly get kustomization monitoring-crds -n flux-system flux --context folly get helmrelease prometheus-operator-crds -n flux-system flux --context folly get kustomization monitoring -n flux-systemAll three should report
Ready. Ifmonitoring-crdsis stuck, re-check the ten CRDs' ownership markers with the verify loop above before assuming a chart problem.
Linked references 1
Runbooks/Adopt Folly Prometheus Operator CRDs β the one-time live ownership stamp and Kustomization wiring that lets folly join monitoring-crds