Skip to content

Fix the documented CRD fallback for existing resources #2843

Closed

Description

@mchmarny

Summary

The manual CRD-upgrade fallback in docs/user/component-catalog.md cannot update an existing CRD. It runs kubectl create and falls back to kubectl replace, but a chart's raw CRD manifest does not carry the live object's metadata.resourceVersion, so Kubernetes rejects the replacement.

This is now the required upgrade path for Helmfile because #2725 intentionally removed the unreliable Helmfile presync hook. It is also the documented recovery path when the generated Helm bundle's apply-crds.sh fails.

Found in review of #2725: #2725 (comment)

Current behavior

The catalog documents:

kubectl create -f "${crd}" 2>/dev/null || kubectl replace -f "${crd}"

For an upgrade, create reaches AlreadyExists; replace then submits the raw chart object without metadata.resourceVersion and fails. The old CRD schema remains installed while the controller may be upgraded.

The generated Helm path already avoids this failure by using server-side apply with Helm's field manager:

kubectl apply --server-side --force-conflicts --field-manager=helm -f "${crd}"

Acceptance criteria

  • The catalog's manual fallback uses the same working update semantics as the generated apply-crds.sh.
  • Helmfile instructions point to that working command as a required pre-upgrade step for ownsCRDs components.
  • The documentation no longer claims create-or-replace is authoritative or equivalent to the generated script.
  • An API-server-backed regression proves the documented command updates an existing CRD and removes a field or spec.versions entry omitted by the target chart.

Metadata

Metadata

Assignees

Labels

area/docstheme/deployer

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions