Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local files transfered to a Kubernentes Persistent Volume?

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.

like image 979
Cristobal Romero Fernandez Avatar asked Nov 06 '17 16:11

Cristobal Romero Fernandez


People also ask

How do I see files in persistent volume in Kubernetes?

First, find out your pvc's mountPath. Your data sits there. Second, you can access it from the pod that uses the PersistentVolumeClaim. Fire up a terminal on the pod and use your favourite tools like ls and df to list files or see stats of the volume usage.

How does the persistent volume works in Kubernetes?

Persistent volumes are independent of the lifecycle of the pod that uses it, meaning that even if the pod shuts down, the data in the volume is not erased. They are defined by an API object, which captures the implementation details of storage such as NFS file shares, or specific cloud storage systems.

Where are persistent volumes stored?

A persistent volume is a piece of storage in a cluster that an administrator has provisioned. It is a resource in the cluster, just as a node is a cluster resource.


1 Answers

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
like image 71
vascop Avatar answered Sep 20 '22 09:09

vascop