Repository navigation
feat(k8s): devops k8s volume move copies a local-path claim to a volume on another node and rebinds it, with argo cd paused and each step checked - #2199
Merged
Conversation
…me on another node and rebinds it, with argo cd paused and each step checked `devops k8s volume move <namespace>/<claim>` does the ten hand steps of k8s/README.md (Local-Path Volume Placement) as one command. The plan reads the claim, its volume, the nodes, the pods that mount the claim, their workloads and the Argo CD Applications that track them, picks the worker node with the most free disk, and refuses a move that cannot run safely. The run pauses Argo CD from the top down, copies with GNU tar over two kubectl exec streams through the API server (one more time when the stream stops), compares counts and digests of the two sides, binds the claim to the new volume without the last-applied annotation and then puts it back, starts the workloads on the target node and resumes Argo CD. Before the delete of the old claim, a failure undoes each change. After it, a failure leaves Argo CD paused and names the saved claim. --plan only reads; --dry-run makes no request. The shared process fake records the input that run_subprocess sends. k8s/README.md replaces the hand steps with the command.
dan-petty
force-pushed
the
feat/2186-volume-move
branch
from
October 24, 2026 23:17
58eee91 to
566ebff
Compare
dan-petty
marked this pull request as ready for review
October 24, 2026 23:24
dan-petty
pushed a commit
that referenced
this pull request
Oct 25, 2026
🤖 I have created a release *beep* *boop* --- ## [0.5.0](v0.4.3...v0.5.0) (2026-10-25) ### Features * **config:** devops config unset removes a key, and an unknown key's error names the line and that command ([#2207](#2207)) ([217e05b](217e05b)), closes [#2201](#2201) * **k8s:** devops k8s volume move copies a local-path claim to a volume on another node and rebinds it, with argo cd paused and each step checked ([#2199](#2199)) ([8efee07](8efee07)), closes [#2186](#2186) ### Bug Fixes * **review:** exclude deleted files and record scanner failures per file ([#1140](#1140)) ([#2204](#2204)) ([cdc5070](cdc5070)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.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.
Summary
devops k8s volume move <namespace>/<claim> [--to-node <node>] [--plan] [--dry-run] [--context <ctx>]does the ten hand steps ofk8s/README.md(Local-Path Volume Placement) as one command. The hand steps had two surprises in the #1634 moves (a dropped exec stream, and a last-applied annotation that made Argo CD refuse the sync), and the owner's own run failed at the first line because one placeholder broke the shell paste.What the command does:
argocd.argoproj.io/tracking-idon the claim and on each workload (the Loki claim comes from a claim template and has no annotation, but its StatefulSet has one). Without--to-node, it picks the worker node with the mostnode.fs.availableBytesfrom the kubelet's/stats/summary. It refuses a claim that is missing or notBound, a claim that no pod mounts, a volume that is not local, a volume on a worker node when--to-nodenames no node, a target that does not exist or is a control-plane node or the node of the volume, a StatefulSet withwhenScaled: Delete, a pod that no Deployment or StatefulSet owns, a tracked Application that does not exist, and the leftovers<claim>-src,<claim>-dstand<claim>-move. A refusal names every problem and changes nothing.bootstrap,clusterand the Application; make<claim>-moveand<claim>-dston the target node; scale to zero; start<claim>-srcwith the old claim read-only; copy with GNU tar over twokubectl execstreams joined bybash -o pipefail(one more time on an empty/dstwhen the stream stops); compare entries, files, bytes of regular files, a metadata digest and a content digest; set both volumes toRetain; delete the copy pods; save and delete the old claim (the point of no return); delete<claim>-moveand reserve its volume for the claim name; make the claim again without the last-applied annotation and the volume controllers' annotations, then put the last-applied value back; scale back and make sure that the pods run on the target node; resume Argo CD in reverse order. The summary prints the new volume, the old volume and the command that deletes it.k8s/README.mdhas a short "Finish a stopped move".--dry-runstarts no process and prints the requests of a move, in order, with placeholders.run_subprocess. The sharedProcessFakenow records theinputthatrun_subprocesssends asstdin; before, the body went into**kwargsand was lost.CONST_K8S_LAST_APPLIED_ANNOTATION, whichsecret_push.pyuses too.k8s/README.mdreplaces the ten hand steps with the command, a list of what it does, the point of no return and the recovery steps. fix(k8s): the volumes of grafana, the prometheus server and loki move off the control-plane node, and their placement exemptions go #2147 runs the three moves with it; this pull request does not move a volume.Tests:
tests/test_k8s_volume_move.py(40 tests) runs on the shared process fake with a scripted cluster: the plan and its target, each refusal, a full move (the exact order of every request that changes the cluster), the claim body without the last-applied annotation and the annotate with the saved value, the copy pods and the copy pipe, a digest difference, an incomplete digest, a dropped copy that is retried once, a second dropped copy, an interrupt, a failed request and a failed undo before the point of no return, a failed create and a pod on the wrong node after it, the dry run, and the command output of each case. No test starts kubectl or bash. They fail onorigin/main(the module does not exist; the fake test fails on its assertion), and they pass withenv PATH=/usr/bin:/bin .venv/bin/python -m pytest.Existing tool considered
pv-migratev3.7.0 (2026-10-23) copies data from one existing claim to another with rsync over SSH.mountneeds one pod with the two claims, which two local volumes on different nodes cannot have.clusterip,loadbalancerandnodeportgo pod to pod, and since v3.7.0 it makes an allow-all NetworkPolicy for its own pods by default, which opens the perimeter ofmonitoringandloggingduring the copy.localtunnels through the workstation, the same path as the tar exec streams, with an sshd and an rsync image and a Helm release for each run, and a new binary on the workstation. It does not make the destination claim on a chosen node, scale the workloads, pause Argo CD, compare the two sides, or bind the original claim name to the new volume. So it would replace the copy step only. The command keeps GNU tar fromdebian:trixie-slim, as the #1634 moves did. Build cost: about 500,000 tokens and 2.5 hours to build with the tests; about 20,000 tokens a year to keep; about 50,000 tokens to fix when kubectl, local-path or Argo CD changes the behavior that it relies on.--planon the live cluster (read-only, 2026-10-24)Node names are replaced with roles.
Item
Closes #2186
Change:
openspec/changes/archive/2026-10-24-2186-volume-move/