adorable-engine-54269
05/07/2025, 4:46 PMbland-article-62755
05/07/2025, 5:12 PMbland-article-62755
05/07/2025, 5:12 PMbland-article-62755
05/07/2025, 5:12 PMbland-article-62755
05/07/2025, 5:13 PMbland-article-62755
05/07/2025, 5:14 PMbland-article-62755
05/07/2025, 5:14 PMharvester-longhorn
)bland-article-62755
05/07/2025, 5:14 PMbland-article-62755
05/07/2025, 5:15 PMadorable-engine-54269
05/07/2025, 5:21 PMbland-article-62755
05/07/2025, 5:27 PM-flat
to the back of $1.
It makes a job that pulls a container and uses dd
to make a block copy from one storage class to the other. This only works for block device volumes!
Licensed under MIT. 🙂bland-article-62755
05/07/2025, 5:28 PM/pvc-disk-flatner bobby-disk-0-bdny7 default bobby-root
bland-article-62755
05/07/2025, 5:28 PMbland-article-62755
05/07/2025, 5:29 PMkubectl
working for your harvester cluster for this script to work.bland-article-62755
05/07/2025, 5:30 PMbland-article-62755
05/07/2025, 5:31 PM./pvc-disk-migrator mtdev-db-data canvas mtdev-db-data-ceph csi-rbd-sc
bland-article-62755
05/07/2025, 5:32 PMcsi-rbd-sc
is a ceph rbd storage class we set up in the cluster.bland-article-62755
05/07/2025, 5:32 PMbland-article-62755
05/07/2025, 5:33 PMadorable-engine-54269
05/07/2025, 5:41 PMbland-article-62755
05/07/2025, 5:42 PMbland-article-62755
05/07/2025, 5:42 PMbland-article-62755
05/07/2025, 5:43 PMbland-article-62755
05/07/2025, 5:43 PMbland-article-62755
05/07/2025, 5:43 PMbland-article-62755
05/07/2025, 5:44 PMbland-article-62755
05/07/2025, 5:44 PMadorable-engine-54269
05/07/2025, 8:38 PMWe got a image backed disk: vmi-2848ae11-328a-4db4-97ed-bdb45d71062d
The default storage class (harvester-longhorn) looks flat.
We're going to make a new 101Gi disk called with the default StorageClass: harvester-longhorn.
jq: error: syntax error, unexpected '[', expecting FORMAT or QQSTRING_START (Unix shell quoting issues?) at <top-level>, line 1:
.metadata.annotations.["<http://pv.kubernetes.io/bind-completed|pv.kubernetes.io/bind-completed>"]
jq: 1 compile error
adorable-engine-54269
05/07/2025, 8:39 PMadorable-engine-54269
05/07/2025, 8:42 PMjq -r '.metadata.annotations.["<http://pv.kubernetes.io/bind-completed|pv.kubernetes.io/bind-completed>"]'
becomes
jq -r '.metadata.annotations["<http://pv.kubernetes.io/bind-completed|pv.kubernetes.io/bind-completed>"]'
adorable-engine-54269
05/07/2025, 8:50 PM❯ ./pvc-disk-flattener cobbler-1-disk-0-ee6gp ops
Looking to flatten cobbler-1-disk-0-ee6gp from image backed
We got a image backed disk: vmi-2848ae11-328a-4db4-97ed-bdb45d71062d
The default storage class (harvester-longhorn) looks flat.
We're going to make a new 101Gi disk called with the default StorageClass: harvester-longhorn.
error: error parsing STDIN: error converting YAML to JSON: yaml: line 16: could not find expected ':'
Waiting for cobbler-1-disk-0-ee6gp-disk-flattener job to complete...Error from server (NotFound): jobs.batch "cobbler-1-disk-0-ee6gp-disk-flattener" not found
bland-article-62755
05/07/2025, 8:59 PMbland-article-62755
05/07/2025, 9:00 PM:
in the yaml and it doesn't know what to call the new disk.adorable-engine-54269
05/07/2025, 9:00 PMbland-article-62755
05/07/2025, 9:01 PMbland-article-62755
05/07/2025, 9:01 PMbland-article-62755
05/07/2025, 9:01 PMadorable-engine-54269
05/07/2025, 9:02 PMbland-article-62755
05/07/2025, 9:02 PMadorable-engine-54269
05/07/2025, 9:02 PMbland-article-62755
05/07/2025, 9:03 PM./pvc-disk-flattener cobbler-1-disk-0-ee6gp ops cobbler-root
bland-article-62755
05/07/2025, 9:08 PMbland-article-62755
05/07/2025, 9:09 PMadorable-engine-54269
05/07/2025, 9:09 PM❯ ./pvc-disk-flattener cobbler-1-disk-0-ee6gp ops cobbler-root
Looking to flatten cobbler-1-disk-0-ee6gp from image backed
We got a image backed disk: vmi-2848ae11-328a-4db4-97ed-bdb45d71062d
The default storage class (harvester-longhorn) looks flat.
We're going to make a new 101Gi disk called sacops-cobbler-root with the default StorageClass: harvester-longhorn.
Error from server (NotFound): persistentvolumeclaims "cobbler-root" not found
error: error parsing STDIN: error converting YAML to JSON: yaml: line 16: could not find expected ':'
Waiting for cobbler-1-disk-0-ee6gp-disk-flattener job to complete...^C
I manually created a pvc claim and checked, it worked manually…
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: test-new-disk
namespace: ops
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
storageClassName: harvester-longhorn
volumeMode: Block
kubectl apply -f test
persistentvolumeclaim/test-new-disk created
kubectl -n ops get pvc test-new-disk -o json |jq -r '.metadata.annotations["pv.kubernetes.io/bind-completed"]'
yes
adorable-engine-54269
05/07/2025, 9:10 PMadorable-engine-54269
05/07/2025, 9:10 PMbland-article-62755
05/07/2025, 9:11 PMbland-article-62755
05/07/2025, 9:11 PMadorable-engine-54269
05/08/2025, 12:54 AM