<p>I am using gocd for ci/cd. Result is tar archive. I need to copy resulting tar to GCE bucket.</p>
<p>I have gocd-agent docker image with included google sdk.</p>
<p>I know how to use gcloud with service account from local machine, but not from inside pod.</p>
<p>How to use service account assigned to pod with gcloud auth on pod?</p>
<p>Final goal is to use gsutil to copy above mentioned archive to bucket in same project.</p>

EnterSB
<p>My first thought would be to create <code>Secret</code> based on the service account, reference it in a pod yaml definiton to mount to some file and then run <code>gcloud auth</code> from the pod using that file. There's more info in Google cloud <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/authenticating-to-cloud-platform#step_4_import_credentials_as_a_secret" rel="nofollow noreferrer">docs</a>.
Another option which is quite new is to use <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity" rel="nofollow noreferrer">Workload Identitiy</a>. Seems you'd need to configure GKE cluster to enable this option. And it's working for some versions of GKE.</p>
