Home > Software design >  How to copy file from k8 pod to GCP storage programmatically?
How to copy file from k8 pod to GCP storage programmatically?

Time:01-13

I am deploying my springboot application image to GCP.My springboot application processes data and creates one file.I want to copy this file to GCP Storage.Can we achieve this from Kubernetes pod to GCP Storage?

CodePudding user response:

Yes you can, you need to install gsutil in your springboot application image then mount your storage token in that container as configmap or secret.

In the end you can run gsutil like this:

gsutil cp source_file gs://my-bucket

CodePudding user response:

You can use GCSFUSE to mount GCS bucket to Kubernetes Pod as a volume. And to copy the file from your Pod to GCS bucket, use Fabric8 Kubernetes Client, which is described in detail here.

You can use the Cloud Storage client libraries to programmatically achieve this.

You can refer this document for uploading files using java

Also, check this thread with python examples for more details.

  • Related