<p>I want to create and remove a job using Google Cloud Builder. Here's my configuration which builds my Docker image and pushes to GCR.</p>

<pre><code># cloudbuild.yaml
steps:
- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '-t', 'gcr.io/xyz/abc:latest','-f','Dockerfile.ng-unit','.']
- name: 'gcr.io/cloud-builders/docker'
  args: ['push', 'gcr.io/xyz/abc:latest']
</code></pre>

<p>Now I want to create a job , I want to run something like </p>

<p><code>kubectl create -R -f ./kubernetes</code></p>

<p>which creates job in kubernetes folder. </p>

<p>I know cloud builder has <code>- name: 'gcr.io/cloud-builders/kubectl'</code> but I can't figure out how to use it. Plus how can I authenticate it to run kubectl commands? How can I use service_key.json </p>

<p>I wasn't able to connect and get cluster credentials. Here's what I did</p>

<blockquote>
  <p>Go to IAM, add another Role to xyz@cloudbuild.gserviceaccount.com. I used Project Editor. </p>
  
  <p>Wrote this on cloudbuild.yaml <code>name: 'gcr.io/cloud-builders/kubectl'
    args: ['create', '-R', '-f','./dockertests/unit-tests/kubernetes']</code></p>
</blockquote>
