How to copy data from GKE to GCS

Tomáš Papež
1 min readSep 8, 2018

Time by time we need to copy data from a container inside Kubernetes (GKE), for example, dumps for debugging. Those files can be pretty big and shared between multiple developers and I don’t like downloading them to my laptop, then I found a way how to do it easily inside google cloud and even Dev friendly.

Go to GCE web interface, connect to cluster viaCloud Shell.

mkdir ~/dumps                #create folder in your home directory
gcsfuse core-dumps ~/dumps #mount storage core-dumps

Find pod name and required file path and name.

kubectl cp <pod_name>:<file_path/file_name> dumps/<file_name>

Disconnect storage:

fusermount -u ~/dumps

If you know those files are temporary and you need them only for few days, it’s good practice to set lifecycle to don’t forget to delete them.

If you have a better way, let me know in comments, thanks.

Sources:

--

--