I'm working on a Python(3.6) project in which I have implemented Google cloud apis, I have setup credentials for Google Cloud via service account. Here's what I have tried:
Obtain Credentials:
def prepare_credentials(cred_file):
from google.oauth2 import service_account
credentials = service_account.Credentials.from_service_account_file(cred_file)
return credentials
And then I have tried to run gcloud container clusters get-credentials $CLUSTER_NAME --zone $ZONE --project $PROJECT
as below:
Run gcloud command via Python's Subprocess:
print(subprocess.call(
'gcloud container clusters get-credentials ' + data['cluster_name'] + ' --zone '
+ data['zone_region']
+ ' --project ' + data['project_id'],
shell=True))
it returns this error:
Fetching cluster endpoint and auth data.
ERROR: (gcloud.container.clusters.get-credentials) ResponseError: code=403, message=Required "container.clusters.get" permission for "projects/brain-183103/zones/europe-west1-d/clusters/numpy".
1
W0629 04:12:00.776926 2222 factory_object_mapping.go:423] Failed to download OpenAPI (Get https://104.197.10.169/swagger-2.0.0.pb-v1: dial tcp 104.197.10.169:443: i/o timeout), falling back to swagger Unable to connect to the server: dial tcp 104.197.10.169:443: i/o timeout
Service Account credentials are working well as I'm using these credentials for various other Google Cloud API calls and also I have set the owner
permission to the project for this service_account.
Have I configured something wrong?
Help me, please!
Thank You, Abdul
owner
. – Abdul Rehman