Answers: <p>The easiest approach does appear to be to use <code>gcloud</code>, as trying to get a kubeconfig without it proved tricky.</p>
  
  <p>Fortunately, <code>gcloud</code>, <code>kubectl</code> and <code>helm</code> are available as a single docker image <code>kiwigrid/gcloud-kubectl-helm</code>. For example:</p>
  
  <pre><code>docker run -it --rm --volume ./gcp-key-file.json:/data/gcp-key-file.json:ro kiwigrid/gcloud-kubectl-helm:2.11.0-224.0.0 bash
  gcloud auth activate-service-account --key-file=/data/gcp-key-file.json
  gcloud container clusters get-credentials dev-cluster --project &lt;project name&gt; --zone &lt;zone&gt;
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2019-01-29T17:29:57.740Z
Answers: 2019-01-29T17:29:57.740Z
Answers: Matt R
Body: <p>I'm setting up our CI (Jenkins pipeline) to deploy apps to a GKE cluster. Our Jenkins sever is running external to GKE or any Google Cloud infrastructure. I'm thinking of using <a href="https://github.com/dtzar/helm-kubectl" rel="nofollow noreferrer">a docker image with helm and kubectl</a> to deploy, but need to set up credentials. On my local dev machine, I authenticate with:</p>
  
  <pre><code>gcloud container clusters get-credentials [CLUSTER_NAME]
  </code></pre>
  
  <p>What would be the best way of setting up credentials for a Jenkins job? Do I have to install and use the <code>gcloud</code> tools on Jenkins, or is there another approach?</p>
  
Tags: <jenkins><kubernetes><continuous-integration><google-cloud-platform>
Title: Deploy to GKE from CI server outside of cluster
UserDisplayName: Matt R
ThreadText: # Deploy to GKE from CI server outside of cluster
  
  (Asked by: username_0 on 2019-01-29)
  
  I'm setting up our CI (Jenkins pipeline) to deploy apps to a GKE cluster. Our Jenkins sever is running external to GKE or any Google Cloud infrastructure. I'm thinking of using [a docker image with helm and kubectl](https://github.com/dtzar/helm-kubectl) to deploy, but need to set up credentials. On my local dev machine, I authenticate with:
  
  ```
  gcloud container clusters get-credentials [CLUSTER_NAME]
  
  ```
  
  What would be the best way of setting up credentials for a Jenkins job? Do I have to install and use the `gcloud` tools on Jenkins, or is there another approach?
  
  **Tags:** jenkins, kubernetes, continuous-integration, google-cloud-platform
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-01-29. Score: 1
  
  The easiest approach does appear to be to use `gcloud`, as trying to get a kubeconfig without it proved tricky.
  
  Fortunately, `gcloud`, `kubectl` and `helm` are available as a single docker image `kiwigrid/gcloud-kubectl-helm`. For example:
  
  ```
  docker run -it --rm --volume ./gcp-key-file.json:/data/gcp-key-file.json:ro kiwigrid/gcloud-kubectl-helm:2.11.0-224.0.0 bash
  gcloud auth activate-service-account --key-file=/data/gcp-key-file.json
  gcloud container clusters get-credentials dev-cluster --project <project name> --zone <zone>
  
  ```
  
  
  ---
  
  