Install kubernetes manifest on an attached cluster using Cloud Build

56 Views Asked by At

In GKE, I have an attached cluster which resides on prem and has kubernetes installed on it using kubeadm.

enter image description here

Now using GCP Cloud Build, I would like to install a k8s app onto it. I have the kubeconfig file of the k8s cluster and the API is exposed using a Public IP.

My Cloud build code looks like

steps:
- name: "gcr.io/cloud-builders/kubectl"
  args:
  - --kubeconfig
  - kubeconfig.yaml
  - apply
  - -f
  - app/on-prem/
  id: 'deploy-to-on-prem'

But this results in

Already have image (with digest): gcr.io/cloud-builders/kubectl
  No cluster is set. To set the cluster (and the region/zone where it is found), set the environment variables
  CLOUDSDK_COMPUTE_REGION=<cluster region> (regional clusters)
  CLOUDSDK_COMPUTE_ZONE=<cluster zone>
  CLOUDSDK_CONTAINER_CLUSTER=<cluster name>

  Optionally, you can specify the kubectl version via KUBECTL_VERSION, taking one of the following values: 1.23 1.24 1.25 1.26 1.27 1.28
  Optionally, you can specify additional parameters for the kubectl 'get-credentials' command via CLOUDSDK_GET_CREDENTIALS_OPTS, such using values as: --internal-ip, --quiet

Is there something missing here or do I need to do this differently ?

0

There are 0 best solutions below