[Fix] Stop Kafka CR delete+recreate on helm upgrade - #309
Closed
tal-haim wants to merge 1 commit into
Closed
Conversation
CEML-724: Kafka/KafkaNodePool were Helm hooks with the default before-hook-creation delete policy, so every helm upgrade recreated the CRs and minted a new KRaft cluster id against retained PVC data. Strimzi CRDs ship via the sub-chart crds/ directory, so these CRs can be plain release-managed manifests. Also expose kafka.storage.deleteClaim (default false) on the KafkaNodePool storage spec. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
Fixes: Kafka broker crash-loops with
Invalid cluster.idafterhelm upgrade --installon a cluster with retained PVCs.Root cause:
KafkaandKafkaNodePoolwere Helm hooks (post-install,post-upgradewith the defaultbefore-hook-creationdelete policy). Every upgrade deleted and recreated the CRs, minting a new KRaft cluster id while the PVC still held the old one.Strimzi ships its CRDs via the sub-chart
crds/directory, so Helm installs CRDs before templates — the Kafka CRs do not need hooks. This PR makes them ordinary release-managed manifests thathelm upgradepatches in place, preserving cluster identity on retained PVCs.Also exposes
kafka.storage.deleteClaim(defaultfalse) on theKafkaNodePoolstorage spec.🛠️ Changes Made
charts/mlrun-ce/templates/kafka/kafka-cluster.yaml— removedhelm.sh/hook/hook-weightannotations from theKafkaCRcharts/mlrun-ce/templates/kafka/kafka-nodepool.yaml— removed hook annotations; renderstorage.deleteClaimfrom values when storage type ispersistent-claimcharts/mlrun-ce/values.yaml— addedkafka.storage.deleteClaim: falsewith documentationcharts/mlrun-ce/README.md— added “Kafka data retention” sectionAGENTS.md— updated Kafka dependency notes and CRD/hook guidancecharts/mlrun-ce/Chart.yaml— bumped0.12.0-rc.6→0.12.0-rc.7✅ Checklist
charts/mlrun-ce/Chart.yaml.deleteClaiminherits default fromvalues.yaml)🧪 Testing
Tested on a real cluster via the on-prem MLRun CE deploy pipeline (fresh install from this branch, then a second
helm upgrade).Fresh install + second upgrade (CEML-724 core scenario)
Upgrade completehelm.sh/hookon Kafka CRsRunning 1/1,Kafka Server startedInvalid cluster.idHook → no-hook migration (upgrade from pre-fix chart)
Simulated the failure seen when upgrading a cluster that was first installed with the hook-based chart (
rc.6) to this fix (rc.7). Helm initially failed with:After applying the one-time migration below, upgrade succeeded (
rc.6→rc.7, rev 2), CR UIDs unchanged, broker healthy.🔗 References
🚨 Breaking Changes?
Existing deployments that installed Kafka with the hook-based chart must run a one-time migration before upgrading to this version.
Hook-created CRs lack Helm ownership metadata (
meta.helm.sh/release-name/meta.helm.sh/release-namespace). When hooks are removed, Helm refuses to adopt the existing CRs and the upgrade fails withinvalid ownership metadata.One-time migration (run once per affected cluster/namespace before
helm upgrade):Fresh installs are unaffected — CRs are created as release-managed resources from the start.
Note: This differs from #307 (cluster-id pinning via init Job + hooks). This PR removes the root cause (hook delete+recreate) rather than working around it.
🔍️ Additional Notes
kafka.storage.deleteClaimdefaults tofalse, retaining Kafka PVCs (and KRaft cluster id) on uninstall. Settrueonly for disposable environments.helm upgraderuns preserve CR UIDs and PVC data — no repeat migration needed.Made with Cursor