Skip to content

Moving data

Whichever method you use, write to a path backed by a PVC. Anything written elsewhere in the container is lost when the Pod restarts or is rescheduled.

Terminal window
kubectl cp ./input.csv <tenant>-prod/my-pod:/data/input.csv # local → Pod
kubectl cp <tenant>-prod/my-pod:/data/output.csv ./output.csv # Pod → local

kubectl cp streams a tar archive through the API server, so the container image needs tar. It has no resume, progress or delta transfer, and a dropped connection restarts the copy from zero. Keep it to files under about 500 MB.

For large datasets, run a Job that pulls from the source (object store, HTTP endpoint, database dump) straight into a PVC. The transfer stays on the cluster network, retries on failure, and doesn’t depend on your machine staying connected. Download once into a PVC and mount that PVC in your workloads, rather than downloading in an initContainer on every Pod start.

apiVersion: batch/v1
kind: Job
metadata:
name: data-import
namespace: <tenant>-prod
spec:
template:
spec:
restartPolicy: OnFailure
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
seccompProfile:
type: RuntimeDefault
containers:
- name: import
image: curlimages/curl:latest
command:
- sh
- -c
- "curl -fSL https://example.com/dataset.tar.gz | tar xz -C /data"
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
volumeMounts:
- name: data
mountPath: /data
volumes:
- name: data
persistentVolumeClaim:
claimName: my-data
  • The securityContext fields are required by PodSecurity restricted. Without them the Job is created but its Pods are denied, and the error shows only in the Job’s events (kubectl describe job data-import).
  • fsGroup makes the fresh volume writable by the non-root user; see Mounting a PVC in a Pod.
  • Outbound traffic is not restricted by default. If you add an egress NetworkPolicy that selects these Pods, it must allow the source and DNS (a ports-only rule for UDP and TCP 53); see NetworkPolicy.
  • For resource requests, deadlines and TTL cleanup, see Jobs and CronJobs.

For large or unreliable transfers from your own machine, run an rsync daemon as a sidecar in the Pod that mounts the PVC and reach it with kubectl port-forward. You get resume, delta transfer and progress reporting. The sidecar must meet PodSecurity restricted like any other container. Ask RCS if you want help setting one up.

A CephFS share stays in your Arbutus project, so a VM there can mount it at the same time as your Pods and move data in or out with no Kubernetes API in the path.

For a shared volume that RCS arranged, ask RCS whether its backing storage can also be mounted outside Kestrel. It isn’t available by default.