Local files transfered to a Kubernentes Persistent Volume?

Cristobal Romero Fernandez picture Cristobal Romero Fernandez · Nov 6, 2017 · Viewed 7.9k times · Source

I'm extremely new to Kubernetes (besides it's not my field) but I got required to be able to execute this practice.

Question is that I need a Handbrake Converter in a containerized pod with a Persistent Volume mounted on a GKE cluster:

  • 3 nodes.
  • node version 1.8.1-gke.1
  • node image Ubuntu

Everything is fine until this point but now I'm not able to upload a folder to that PV from my local machine.

What I have tried is a ssh connection to the node and then a sudo docker exec -ti containerId bash but I just got rpc error: code = 13 desc = invalid header field value "oci runtime error: exec failed: container_linux.go:247: starting container process caused \"exec: \\\"bash\\\": executable file not found in $PATH\"\n".

Thanks in advance.

Answer

vascop picture vascop · Nov 6, 2017

To transfer local files to a kubernetes pod, use kubectl cp:

kubectl cp /root/my-local-file my-pod:/root/remote-filename

or

kubectl cp /root/my-local-file my-namepace/my-pod:/root/remote-filename -c my-container

The namespace can be omitted (and you'll get the default), and the container can be omitted (you'll get the first in the pod).

For SSH'ing you need to go through kubectl as well:

kubectl exec -it <podname> -- /bin/sh