Skip to content

PB-12512: Add Helm hooks for proper CRD lifecycle and monitoring resource cleanup#909

Open
vk-px wants to merge 2 commits into
helm4-support-3.1.0-basefrom
pb-12512-final
Open

PB-12512: Add Helm hooks for proper CRD lifecycle and monitoring resource cleanup#909
vk-px wants to merge 2 commits into
helm4-support-3.1.0-basefrom
pb-12512-final

Conversation

@vk-px

@vk-px vk-px commented May 16, 2026

Copy link
Copy Markdown

PB-12512: Add Helm hooks for proper CRD lifecycle and monitoring resource cleanup

Summary

This PR adds missing Helm hook operations for PX-Backup Helm installation to ensure proper ordering and lifecycle management of Custom Resource Definitions (CRDs) and monitoring resources.

Changes

1. CRD Helm Hooks (8 files)

Added Helm hook annotations to all Prometheus Operator CRDs to ensure they are created/updated before the main chart resources:

  • crd-alertmanager.yaml
  • crd-alertmanagerconfigs.yaml
  • crd-podmonitor.yaml
  • crd-probes.yaml
  • crd-prometheus.yaml
  • crd-prometheusrules.yaml
  • crd-servicemonitor.yaml
  • crd-thanosrulers.yaml

Annotations added:

  • helm.sh/hook: pre-install,pre-upgrade
  • helm.sh/hook-delete-policy: before-hook-creation
  • helm.sh/hook-weight: "-5"

2. Monitoring Resources Helm Hooks

Added post-install,post-upgrade hooks to ensure monitoring CR instances are created after CRDs are available:

  • pxcentral-alertmanager.yaml - Alertmanager CR
  • pxcentral-prometheus.yaml - Prometheus, ServiceMonitor, and PrometheusRule CRs

3. Pre-Delete Cleanup Job (New File)

Added pxcentral-monitoring-cleanup.yaml - A new cleanup Job that runs on helm uninstall to properly delete Prometheus Operator custom resources before the CRDs are removed:

  • ServiceAccount, ClusterRole, and ClusterRoleBinding for cleanup permissions
  • Job that deletes: Prometheus, Alertmanager, ServiceMonitor, and PrometheusRule resources

4. Dynamic UI Module Configuration

Updated pxcentral-ui-configmap.yaml to dynamically build FRONTEND_ENABLED_MODULES based on enabled features:

  • Base modules: COMPANY, LH, USERS, SSO
  • Conditionally adds: PXBACKUP, PXMONITOR, PXLS based on respective .Values flags

Why These Changes?

  1. Install/Upgrade ordering: CRDs must exist before Custom Resources (Prometheus, Alertmanager, etc.) can be created. Using pre-install/pre-upgrade and post-install/post-upgrade hooks ensures proper ordering.
  2. Clean uninstall: Without the cleanup job, Custom Resources would become orphaned or cause errors when CRDs are deleted before the CRs.
  3. Helm 4 compatibility: These changes align with Helm best practices for CRD management.
  4. UI module flexibility: Frontend modules are now dynamically configured based on what's actually enabled.

Testing Performed

  • Fresh install of px-central chart
  • Upgrade from previous version
  • Helm uninstall (verify cleanup job runs successfully)
  • Verify UI shows correct modules based on enabled features

K8s only cluster (without/with CRDS) successfull
helm 4 install -- successfull
helm 3 install/ helm 4 upgrade -- successfull
helm 4 install/ helm 4 upgrade -- successfull
helm 3 install -- successfull

RKE2 cluster (without/with CRD) successfull
helm 4 install -- successfull
helm 3 install/ helm 4 upgrade -- successfull
helm 4 install/ helm 4 upgrade -- successfull
helm 3 install -- successfull

portworx cluster (with/without CRDS) successfull
helm 4 install -- successfull
helm 3 install/ helm 4 upgrade -- successfull
helm 4 install/ helm 4 upgrade -- successfull
helm 3 install -- successfull

@vk-px vk-px requested a review from px-kesavan May 16, 2026 05:18
@vk-px vk-px self-assigned this May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant