Search code examples
google-cloud-platformgoogle-kubernetes-enginegoogle-cloud-build

GCP Cloudbuild deploy to GKE


I've create a cloudbuild.yaml that deploys my Helm application on a GKE cluster. After connecting to the cluster I run a simple kubectl get pods -A and all works, but when I run a helm list -A i got this error

Get "https://1.2.3.4/version": getting credentials: exec: executable gke-gcloud-auth-plugin not found
It looks like you are trying to use a client-go credential plugin that is not installed.

I've even tryed to add a step that shows the kubeconfig file and I can see the field command: gke-gcloud-auth-plugin

This is my cloudbuild.yaml file


  - id: 'kubectl-info'
    name: 'gcr.io/cloud-builders/kubectl'
    args: ['cluster-info']
    waitFor: ['-']
    env:
      - KUBECONFIG=/builder/home/.kube/config
      - CLOUDSDK_COMPUTE_REGION=$_DEFAULT_REGION
      - CLOUDSDK_CONTAINER_CLUSTER=$_GKE_NAME
      - USE_GKE_GCLOUD_AUTH_PLUGIN=True
  
  
  - id: 'helm-status'
    name: 'alpine/helm:3.11.2'
    args: ['list', '-A']
    waitFor: ['kubectl-info'],
    env:
      - KUBECONFIG=/builder/home/.kube/config
      - USE_GKE_GCLOUD_AUTH_PLUGIN=True

Solution

  • Check do you have an image where both Helm and gke-gcloud-auth-plugin are installed? Then you can use that image to run the helm commands. Otherwise, you need to install gcloud, gke-gcloud-auth-plugin and then run the Helm commands in the same step.

    You can refer to rebuild this: Using helm tool builder with Google Container Engine check the gcloud version present on CloudBuild worker does not have the plugin, make sure you are pulling the latest one that has it by adding --pull to the steps of that build.