Skip to content

Migrate node-red storage to Longhorn#2549

Open
Copilot wants to merge 6 commits into
masterfrom
copilot/migrate-node-red-storage-to-longhorn
Open

Migrate node-red storage to Longhorn#2549
Copilot wants to merge 6 commits into
masterfrom
copilot/migrate-node-red-storage-to-longhorn

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

Node-red's PVC had no explicit storage class (falling back to the cluster default / NFS-backed). This migrates it to Longhorn, consistent with esphome, home-assistant-dad, and other home-automation workloads.

Changes

  • pvc.yaml (new): declares node-red-data-longhorn — 1Gi, storageClass: longhorn, ReadWriteOnce
  • pvc-nfs.yaml (new): explicitly manages the legacy node-red-data NFS PVC with helm.sh/resource-policy: keep, preventing Helm from deleting it during the upgrade when existingClaim is set
  • helmrelease.yaml:
    • nodeSelector: storage: longhorn — pins pod to Longhorn-capable nodes
    • persistence.data.existingClaim: node-red-data-longhorn — uses pre-created Longhorn PVC
    • additionalVolumes — exposes old node-red-data NFS PVC to the init container without mounting it in the main container
    • initContainers: data-migration — one-shot busybox:1.36.1 container that cp -as from old NFS volume to new Longhorn volume; idempotent (skips if destination is non-empty)
  • kustomization.yaml: adds pvc.yaml and pvc-nfs.yaml to resources; snapshots.yaml removed as Longhorn handles snapshots automatically for all volumes
  • .github/workflows/render-helm-templates.yaml (new): renders both the base-branch and PR-branch versions of any changed helmrelease*.yaml and posts a unified diff to the GitHub Step Summary, so the resulting Kubernetes manifests can be reviewed before merging

Migration flow

init container (data-migration)
  /old-data  ← node-red-data       (legacy NFS PVC, read-only)
  /new-data  ← node-red-data-longhorn (Longhorn PVC)
  cp -a /old-data/. /new-data/   # runs once; skipped on subsequent boots

main container
  /data      ← node-red-data-longhorn

Once the migration is confirmed successful the init container, additionalVolumes entry, and the old node-red-data PVC (along with pvc-nfs.yaml) can be cleaned up.

Copilot AI linked an issue Apr 4, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Migrate Node-RED storage to Longhorn Migrate node-red storage to Longhorn Apr 4, 2026
Copilot AI requested a review from jeffborg April 4, 2026 01:56
Copy link
Copy Markdown
Owner

@jeffborg jeffborg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the snapshot job longhorn does this Automatically for all

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 4, 2026

We don't need the snapshot job longhorn does this Automatically for all

Removed snapshots.yaml and dropped it from kustomization.yaml in e2fb2d9.

Copilot AI requested a review from jeffborg April 4, 2026 03:26
persistence:
data:
enabled: true
existingClaim: node-red-data-longhorn
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause the existing nfs pvc to be destroyed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. When existingClaim is set, Helm removes the old PVC from its managed resource set and will delete it on the next helm upgrade. Fixed in 5f4f426 by adding pvc-nfs.yaml — a Kustomize-managed declaration of the node-red-data PVC with helm.sh/resource-policy: keep, which prevents Helm from deleting it during the upgrade. Flux's kustomize-controller will apply this annotation before Helm reconciles.

Copilot AI requested a review from jeffborg April 4, 2026 03:32
Copy link
Copy Markdown
Owner

@jeffborg jeffborg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy across from the other unmerged pr the helm diff tool. I'm not sure this is going to work without seeing the rendered output

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 4, 2026

Copy across from the other unmerged pr the helm diff tool. I'm not sure this is going to work without seeing the rendered output

Added in d9027b9. The workflow (copied from PR #2532) is now live on this PR — it triggers on any helmrelease*.yaml change, renders both the base and PR versions using the existing render_template.sh, and posts a unified diff to the GitHub Step Summary so you can see the exact Kubernetes manifest changes before merging.

Copilot AI requested a review from jeffborg April 4, 2026 03:58
Copy link
Copy Markdown
Owner

@jeffborg jeffborg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helm render fails

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 4, 2026

Helm render fails

Fixed in fd30db2. The k8s-at-home common chart library expects initContainers to be a map (keyed by container name), not a list — changed from - name: data-migration (list) to data-migration: (map key). The render workflow will re-run on this commit and should pass now.

Copilot AI requested a review from jeffborg April 4, 2026 04:14
@jeffborg jeffborg marked this pull request as ready for review April 24, 2026 21:01
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.

Migrate node red storage to longhorn

2 participants