How can I make my worker (in GCP) access files in google cloud storage?
My function with @remote decorator reads csv file from the google cloud storage. For this, in setup commands in the cluster yaml, I added ‘pip install gcsfs’.
What I observed is that
the function executed in the head node can read the csv without error.
the function executed in the worker node CANNOT read the csv file.
I tried to access the file on gcs (gs://mybucket/myexample.csv), but it returns error like below:
“ServiceException: 401 Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object.”
When compared worker and head VM instance, I found that the head has the following which is missing in the worker.
Cloud API access scopes
Allow full access to all Cloud APIs
I guess the problem will be resolved if my worker is created with full access to all Cloud API’s, and would like to ask how it can be done.
@prakhar_agrawal if you have your service account’s private key (json file) and that service account has access to GCS, then yes it should work; but setting environment variable in python as runtime is never a really good idea… At least set it before running your software so that it can be used by other services if required.
Again, if your service account does not have GCS access, your proposal won’t work. Hence giving the appropriate permissions to the service account in GCS.
Hi @philippe-boyd-maxa yes my service account’s private key(json file ) has access to the gcs. That’s why i am worried why is that not working because in our current kubernetes implementation we mount it as config map and pick it from there. Not sure why its not working here. But when i try this way serviceAccounts:
- email: my-gcs-sa@my-project-id.iam.gserviceaccount.com
scopes:
- https://www.googleapis.com/auth/cloud-platform
it actually tries to create another i-am-role which i am pretty sure my service account does not have access to