Skip to content

feat: install kube-prometheus-stack CRDs during argocd install#515

Open
venkatamutyala wants to merge 4 commits into
mainfrom
feat/install-kube-prometheus-stack-crds-with-argocd
Open

feat: install kube-prometheus-stack CRDs during argocd install#515
venkatamutyala wants to merge 4 commits into
mainfrom
feat/install-kube-prometheus-stack-crds-with-argocd

Conversation

@venkatamutyala

Copy link
Copy Markdown
Contributor

Summary

  • handle_argocd now installs the kube-prometheus-stack CRDs as part of its pre-commands (right after the ArgoCD CRDs), replicating the kube-prometheus-stack-crds ArgoCD Application from platform-helm-chart-platform with plain kubectl.

How it works

  • The chart version is read from VERSIONS/glueops.yaml (kube_prometheus_stack_version) in production, like the other components — added by feat: add kube_prometheus_stack_version to generated VERSIONS/glueops.yaml terraform-module-cloud-multy-prerequisites#648. Dev mode falls back to the targetRevision pinned on main of platform-helm-chart-platform. A clear error is shown if the key is missing (older VERSIONS/glueops.yaml — re-run terraform to regenerate).
  • The whole CRD folder (charts/kube-prometheus-stack/charts/crds/crds) is sparse-cloned from prometheus-community/helm-charts at tag kube-prometheus-stack-<version> and applied in one kubectl apply --server-side --force-conflicts -R -f — no hardcoded file list, matching the app's directory.recurse: true.
  • Server-side apply is the kubectl equivalent of the app's Replace=true: the prometheus/alertmanager CRDs blow past the 256KB last-applied-configuration annotation limit of client-side apply.

Testing

  • bash -n syntax check passes.
  • Verified the sparse clone at tag kube-prometheus-stack-59.1.0 materializes exactly the 10 CRD yamls; full apply needs a live cluster (--server-side can't pair with --dry-run=client).

🤖 Generated with Claude Code

Replicates the kube-prometheus-stack-crds ArgoCD app from
platform-helm-chart-platform via kubectl: the chart version is read from
VERSIONS/glueops.yaml (kube_prometheus_stack_version, added by
GlueOps/terraform-module-cloud-multy-prerequisites#648), the CRD folder
is sparse-cloned from prometheus-community/helm-charts at that tag, and
applied server-side (the prometheus CRDs are too large for client-side
apply, mirroring the app's Replace=true).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
venkatamutyala and others added 3 commits July 7, 2026 15:35
The command block is printed before being eval'd so users can copy it
to re-run or debug (the set -x trace alone references a temp dir that
is deleted afterwards, so it is not re-runnable as copied).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Replaces the set -x traces around the helm diff/upgrade commands and
the argocd pre-commands with a clean echo of the exact command string
before it is eval'd, so users can copy it to re-run or debug (e.g. swap
'helm diff upgrade' for 'helm template').

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Run pre_commands and install_kube_prometheus_stack_crds inside a
  tested condition so failures reach the retry/continue handler instead
  of set -e killing the whole session (the old bare eval made the
  $? check dead code).
- Keep the echoed pre_commands fully copy-pastable by moving the CRD
  function call out of the string; the function prints its own
  self-contained block.
- Chain the CRD block with && (fail-fast survives the suspended set -e)
  and clean up the temp dir on the failure path.
- GIT_TERMINAL_PROMPT=0 so GitHub auth/rate-limit prompts fail fast
  instead of hanging.
- Fix the helm template hint: --allow-unreleased is helm-diff-only and
  must be dropped when swapping to template.
- Drop unused 'crd' local.

Failure paths (missing version key, nonexistent tag, kubectl failure)
and the success path verified with a stubbed harness: the menu loop
survives, no temp dirs leak, echoed block matches what runs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@venkatamutyala

Copy link
Copy Markdown
Contributor Author

Migration sequencing (from the multi-agent review): the old kube-prometheus-stack-crds ArgoCD app in platform-helm-chart-platform must be removed in two phases — GlueOps/platform-helm-chart-platform#1384 (Release N) strips its finalizer and automated sync so a later release can delete the template without cascade-deleting the CRDs and every monitoring CR cluster-wide. Until then, this PR's kubectl apply coexists safely with the app as long as both pin the same chart version (currently 59.1.0). Full order: terraform-module-cloud-multy-prerequisites#648 → this PR → #1384 → follow-up that deletes the app template.

venkatamutyala added a commit to GlueOps/platform-helm-chart-platform that referenced this pull request Jul 7, 2026
Removes the resources-finalizer and the automated sync policy (prune +
selfHeal) from the kube-prometheus-stack-crds Application. The CRDs are
now installed by captain_utils via kubectl server-side apply
(GlueOps/codespaces#515, versioned through VERSIONS/glueops.yaml by
GlueOps/terraform-module-cloud-multy-prerequisites#648).

Without the finalizer, deleting the Application in a future release is
non-cascading: the CRDs (and every CR of those kinds cluster-wide) are
orphaned in place instead of garbage-collected. Dropping automated sync
stops selfHeal from reverting kubectl-applied CRD updates during the
transition.

BREAKING CHANGE: after upgrading, and before the follow-up release deletes this Application, verify it has no finalizer — otherwise the delete cascades and wipes the kube-prometheus-stack CRDs and all monitoring CRs. Verify with `kubectl get application kube-prometheus-stack-crds -n glueops-core -o jsonpath='{.metadata.finalizers}'` and expect empty output; if it is non-empty, strip it first with `kubectl patch application kube-prometheus-stack-crds -n glueops-core --type merge -p '{"metadata":{"finalizers":null}}'`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
venkatamutyala added a commit to GlueOps/platform-helm-chart-platform that referenced this pull request Jul 7, 2026
Removes the resources-finalizer and the automated sync policy (prune +
selfHeal) from the kube-prometheus-stack-crds Application. The CRDs are
now installed by captain_utils via kubectl server-side apply
(GlueOps/codespaces#515, versioned through VERSIONS/glueops.yaml by
GlueOps/terraform-module-cloud-multy-prerequisites#648).

Without the finalizer, deleting the Application in a future release is
non-cascading: the CRDs (and every CR of those kinds cluster-wide) are
orphaned in place instead of garbage-collected. Dropping automated sync
stops selfHeal from reverting kubectl-applied CRD updates during the
transition.

BREAKING CHANGE: after upgrading, and before the follow-up release deletes this Application, verify it has no finalizer — otherwise the delete cascades and wipes the kube-prometheus-stack CRDs and all monitoring CRs. Verify with `kubectl get application kube-prometheus-stack-crds -n glueops-core -o jsonpath='{.metadata.finalizers}'` and expect empty output; if it is non-empty, strip it first with `kubectl patch application kube-prometheus-stack-crds -n glueops-core --type merge -p '{"metadata":{"finalizers":null}}'`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant