serhii.net

In the middle of the desert you can say anything you want

15 Jan 2025

Kubernetes / Rancher much better way to copy data to PVCs

apiVersion: v1
kind: Pod
metadata:
  name: temp-pod
  namespace: CHANGEME-ns
spec:
  restartPolicy: Never
  containers:
    - name: temp-pod
      image: alpine:latest # Use a lightweight image
      command: ["sleep", "3600"] # Keep the pod running for 1 hour
      volumeMounts: # Mount the persistent volume
        - name: data
          mountPath: /data
  volumes: # Specify the persistent volume claim
    - name: data
      persistentVolumeClaim:
        claimName: CHANGEME-pvc

So basically trivial temporary pod done specifically to copy stuff to a PVC that auto-kills itself in 1h w/ no need to do anything for this — ty KM for this!1

Then one can happily copy stuff from there using the usual:

❯ kubectl cp CHANGEME-ns/temp-pod:/data/project/train7/ .
# as well as 
kubectl exec -it temp-pod -n CHANGEME-ns -- sh

ADDITIONALLY, I had issues cp ing things larger than 6gb. Reminder to myself that one can tar things or just transfer in separate parts.


  1. See also 240131-1535 Setup for Dockerfiles where you can look around before running for an overkill option for this that I wouldn’t use anymore ever. ↩︎

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus