<p>I'm trying to deploy my code placed in bitbucket repo to Kubernetes clusters available in google cloud. I've created a trigger which react when I push new changes to bitbucket repo.</p>
<p>I mean:</p>
<p><a href="https://i.stack.imgur.com/YkK1h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YkK1h.png" alt="enter image description here" /></a></p>
<p>Based on guidance: <a href="https://cloud.google.com/build/docs/deploying-builds/deploy-gke#automating_deployments" rel="nofollow noreferrer">https://cloud.google.com/build/docs/deploying-builds/deploy-gke#automating_deployments</a> I've created: <code>cloudbuild.yaml</code> file with content:</p>
<pre><code>steps:
  - name: &quot;gcr.io/cloud-builders/gke-deploy&quot;
    args:
    - run
    - --filename=${_TECH_RADAR_KUB_CONFIG_LOCATION}
    - --image=gcr.io/java-kubernetes-clusters-test/bitbucket.org/intivetechradar/technology-radar-be:${SHORT_SHA}
    - --location=${_TECH_RADAR_GKE_LOCATION}
    - --cluster=${_TECH_RADAR_CLUSTER_NAME}
    env:
      - 'SHORT_SHA=$SHORT_SHA'
options:
  logging: CLOUD_LOGGING_ONLY
</code></pre>
<p>In my repo I additionally I have additionally <code>deployment.yaml</code> file with Kuberneties config:</p>
<pre><code>apiVersion: &quot;apps/v1&quot;
kind: &quot;Deployment&quot;
metadata:
  name: &quot;java-kubernetes-clusters-test&quot;
  namespace: &quot;default&quot;
  labels:
    app: &quot;java-kubernetes-clusters-test&quot;
spec:
  replicas: 3
  selector:
    matchLabels:
      app: &quot;java-kubernetes-clusters-test&quot;
  template:
    metadata:
      labels:
        app: &quot;java-kubernetes-clusters-test&quot;
    spec:
      containers:
        - name: &quot;technology-radar-be-1&quot;
          image: &quot;gcr.io/java-kubernetes-clusters-test/bitbucket.org/intivetechradar/technology-radar-be:SHORT_SHA&quot;
</code></pre>
<p>My build is starting but got stack on issue MANIFEST UNKNOWN like below:
<a href="https://i.stack.imgur.com/Egm3i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Egm3i.png" alt="enter image description here" /></a></p>
<p>How can I solve this problem? Can I somehow let Kubernetes engine know that such manifest exits in additional pre step in cloudbuild.yaml file?
I would be grateful for help.
Thanks!</p>
<p><strong>UPDATE</strong>:</p>
<p>I'm trying to use <strong>cloudbuild.yaml</strong> like below:</p>
<pre><code>substitutions:
  _CLOUDSDK_COMPUTE_ZONE: us-central1-c  # default value
  _CLOUDSDK_CONTAINER_CLUSTER: kubernetes-cluster-test      # default value

steps:
  - id: 'build test image'
    name: 'gcr.io/cloud-builders/docker'
    args: ['build', '-t', 'gcr.io/${_TECH_RADAR_PROJECT_ID}/technology-radar-be/master:$SHORT_SHA', '.']
  - id: 'push test core image'
    name: 'gcr.io/cloud-builders/docker'
    args: ['push', 'gcr.io/${_TECH_RADAR_PROJECT_ID}/technology-radar-be/master:$SHORT_SHA:$SHORT_SHA']
  - id: 'set test core image in yamls'
    name: 'ubuntu'
    args: ['bash','-c','sed -i &quot;s,${_TECH_CONTAINER_IMAGE},gcr.io/$PROJECT_ID/technology-radar-be/$master:$SHORT_SHA,&quot; deployment.yaml']
  - name: 'gcr.io/cloud-builders/kubectl'
    args: ['apply', '-f', 'deployment.yaml']
    env:
      - 'CLOUDSDK_COMPUTE_ZONE=${_CLOUDSDK_COMPUTE_ZONE}'
      - 'CLOUDSDK_CONTAINER_CLUSTER=${_CLOUDSDK_CONTAINER_CLUSTER}'
options:
  logging: CLOUD_LOGGING_ONLY
</code></pre>
<p>The last error message is:
<a href="https://i.stack.imgur.com/eAoah.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eAoah.png" alt="enter image description here" /></a></p>
<p>Is there something wrong with my <code>Dockerfile</code> definition? :</p>
<pre><code>FROM maven:3.8.2-jdk-11 as builder
ARG JAR_FILE=target/docker-demo.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT [&quot;java&quot;, &quot;-jar&quot;, &quot;/app.jar&quot;]
</code></pre>
<p>pom.xml:</p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;parent&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
        &lt;version&gt;2.7.6&lt;/version&gt;
        &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
    &lt;/parent&gt;
    &lt;groupId&gt;com.example&lt;/groupId&gt;
    &lt;artifactId&gt;docker-kubernetes&lt;/artifactId&gt;
    &lt;version&gt;0.0.1&lt;/version&gt;
    &lt;name&gt;docker-kubernetes&lt;/name&gt;
    &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
    &lt;properties&gt;
        &lt;java.version&gt;11&lt;/java.version&gt;
    &lt;/properties&gt;
    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
            &lt;scope&gt;runtime&lt;/scope&gt;
            &lt;optional&gt;true&lt;/optional&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
            &lt;scope&gt;test&lt;/scope&gt;
        &lt;/dependency&gt;
    &lt;/dependencies&gt;

    &lt;build&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;
        &lt;finalName&gt;docker-demo&lt;/finalName&gt;
    &lt;/build&gt;
&lt;/project&gt;
</code></pre>
<p>Screenshot from project tree:
<a href="https://i.stack.imgur.com/PkcyF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PkcyF.png" alt="enter image description here" /></a></p>
<p>Local deployment works:</p>
<p><a href="https://i.stack.imgur.com/5vf3i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5vf3i.png" alt="enter image description here" /></a></p>

Krzysztof Michalski
<p>Not sure but if you look at the error it's trying to fetch the</p>
<p><code>gcr.io/java-kubernetes-clusters-test/bitbucket.org/intivetechradar/technology-radar-be/SHORT_SHA</code> not <code>gcr.io/java-kubernetes-clusters-test/bitbucket.org/intivetechradar/technology-radar-be:SHORT_SHA</code> it's not using <code>:</code> before the <strong>TAG</strong> are you building images ?</p>
<p><strong>Update</strong> :</p>
<p>Just tested this file with cloud build and GKE working for me : <a href="https://github.com/harsh4870/basic-ci-cd-cloudbuild/blob/main/cloudbuild-gke.yaml" rel="nofollow noreferrer">https://github.com/harsh4870/basic-ci-cd-cloudbuild/blob/main/cloudbuild-gke.yaml</a></p>
<p>However you can use the <strong>cloudbuild.yaml</strong></p>
<pre><code>substitutions:
    _CLOUDSDK_COMPUTE_ZONE: us-central1-c  # default value
    _CLOUDSDK_CONTAINER_CLUSTER: standard-cluster-1      # default value
steps:
- id: 'build test image'
  name: 'gcr.io/cloud-builders/docker'
  args: ['build', '-t', 'gcr.io/$PROJECT_ID/$REPO_NAME/$BRANCH_NAME:$SHORT_SHA', '.']
- id: 'push test core image'
  name: 'gcr.io/cloud-builders/docker'
  args: ['push', 'gcr.io/$PROJECT_ID/$REPO_NAME/$BRANCH_NAME:$SHORT_SHA']
- id: 'set test core image in yamls'
  name: 'ubuntu'
  args: ['bash','-c','sed -i &quot;s,TEST_IMAGE_NAME,gcr.io/$PROJECT_ID/$REPO_NAME/$BRANCH_NAME:$SHORT_SHA,&quot; deployment.yaml']
- name: 'gcr.io/cloud-builders/kubectl'
  args: ['apply', '-f', 'deployment.yaml']
  env:
  - 'CLOUDSDK_COMPUTE_ZONE=${_CLOUDSDK_COMPUTE_ZONE}'
  - 'CLOUDSDK_CONTAINER_CLUSTER=${_CLOUDSDK_CONTAINER_CLUSTER}'
</code></pre>
<p><strong>deployment.yaml</strong></p>
<pre><code>apiVersion: &quot;apps/v1&quot;
kind: &quot;Deployment&quot;
metadata:
  name: &quot;java-kubernetes-clusters-test&quot;
  namespace: &quot;default&quot;
  labels:
    app: &quot;java-kubernetes-clusters-test&quot;
spec:
  replicas: 3
  selector:
    matchLabels:
      app: &quot;java-kubernetes-clusters-test&quot;
  template:
    metadata:
      labels:
        app: &quot;java-kubernetes-clusters-test&quot;
    spec:
      containers:
        - name: &quot;technology-radar-be-1&quot;
          image: TEST_IMAGE_NAME
</code></pre>
