'cloud-build + gke-deploy app name or label are ignored

I have this config on a cloudbuild.yaml file:

- name: 'gcr.io/cloud-builders/gke-deploy'
args:
  - run
  - --app=doc-io
  - --namespace=frontend
  - --cluster=cluster-dev
  - --location=europe-west1-b
  - --image=gcr.io/${PROJECT_ID}/github.com/ourprojet/docs-io:dev-${SHORT_SHA}
  - --version=dev-${SHORT_SHA}

But this creates a new workload in GKE named "docs-io" instead of deploying my latest docker image to the existing workload "doc-io".

No matter what I do on the cloud-build side, even with adding the env variables _K8S_APP_NAME or _K8S_LABELS directly in cloud-build config - it creates a new workload on GKE named docs-io.

I haven't been able to find anywhere what is the default "workloads" name taken by cloud-build or gke-deploy nor how to override it.

Has anyone encountered this issue? Any clue how to indicate where the docker deployment has to happen?



Solution 1:[1]

Alright, it's easy to miss from the documentation but what one has to do is to keep the yaml file generated at the creation of a workload (easy to recreate otherwise).

Otherwise, as mentioned by Gari Singh as a comment of my question, a new workload will be generated (or replacing the previous one).

Thus, in the workload config file, no need for any specific tag (image level) and simply put it in a Google Storage folder. Then:

# GKE run deploy
- name: 'gcr.io/cloud-builders/gke-deploy'
args:
  - run
  - --filename=gs://path/to/config/myserviceconfig.yml
  - ...

And this way you get a clean deployment on your GKE cluster.

The doc is a bit miss leading as to what happen without the filename argument, hope it helps.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jay Cee