GoogleCloudPlatform / continuous-deployment-on-kubernetes

Get up and running with Jenkins on Google Kubernetes Engine
Apache License 2.0
1.6k stars 890 forks source link

jenkinsfile access another gke cluster for separating dev and production cluster. #104

Closed g3gurung closed 6 years ago

g3gurung commented 7 years ago

I am having a GKE cluster of (jenkins + dev), but I have a separate production GKE cluster so I don't know how to access and deploy(canary and production) from jenkins cluster(via jenkinsfile) to the production cluster.

echo 'accessing production project/cluster'
sh("gcloud container clusters get-credentials my_other_cluster --zone europe-west3-a --project my_other_project")
sh("kubectl get po")
sh("kubectl get svc")

I did the above in jenkinsfile but it is giving this error:

Fetching cluster endpoint and auth data.
ERROR: (gcloud.container.clusters.get-credentials) ResponseError: code=403, message=Required "container.clusters.get..."
viglesiasce commented 6 years ago

You need to ensure that the cluster that Jenkins runs in has the scopes enabled to allow it to get credentials.

viglesiasce commented 6 years ago

Closing as this is out of scope for the current tutorial. Will look to make an update in the future to include multiple clusters.