<p>The following deployment file is working if I'm uploading it from my local machine.</p>

<pre><code>kind: Deployment
apiVersion: apps/v1
metadata:
  name: api
  namespace: app
spec:
  replicas: 2
  selector:
    matchLabels:
      run: api
  template:
    metadata:
      labels:
        run: api
    spec:
      containers:
      - name: api
        image: gcr.io/myproject/api:1535462260754
        ports:
        - containerPort: 8080
        readinessProbe:
          httpGet:
            path: /_ah/health
            port: 8080
          initialDelaySeconds: 10
          periodSeconds: 5
</code></pre>

<p>The same one is on remote Compute Engine machine which running Jenkins. On this machine, with ssh I'm also able to apply this config. Under the Jenkins shell execute it's always throws </p>

<pre><code>error: unable to recognize "./dist/cluster/api.deployment.yaml": no matches for kind "Deployment" in version "apps/v1"
</code></pre>

<p>I tried to change <code>apiVersion</code> to <code>apps/v1beta1</code> and to <code>extensions/v1beta1</code> as well.
Don't know what to try else.</p>

<p><strong>Update 1</strong></p>

<p>kubectl version on Compute Engine:</p>

<pre><code>Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff0 88eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:17:28Z", GoVersion:"go1.10.3", Compiler:"gc", Pla tform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"9+", GitVersion:"v1.9.7-gke.5", GitCommit:"9b635efce81582e1da13b3 5a7aa539c0ccb32987", GitTreeState:"clean", BuildDate:"2018-08-02T23:42:40Z", GoVersion:"go1.9.3b4", Compiler:"gc ", Platform:"linux/amd64"}
</code></pre>

<p><strong>Update 2</strong></p>

<p>Run inside Jenkins job shown this.</p>

<pre><code>Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:17:28Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
Error from server (Forbidden): &lt;html&gt;&lt;head&gt;&lt;meta http-equiv='refresh' content='1;url=/securityRealm/commenceLogin?from=%2Fversion%3Ftimeout%3D32s'/&gt;&lt;script&gt;window.location.replace('/securityRealm/commenceLogin?from=%2Fversion%3Ftimeout%3D32s');&lt;/script&gt;&lt;/head&gt;&lt;body style='background-color:white; color:white;'&gt;


Authentication required
&lt;!--
You are authenticated as: anonymous
Groups that you are in:

Permission you need to have (but didn't): hudson.model.Hudson.Read
... which is implied by: hudson.security.Permission.GenericRead
... which is implied by: hudson.model.Hudson.Administer
--&gt;

&lt;/body&gt;&lt;/html&gt;
</code></pre>

<p>Thanks to <strong>@csanchez</strong> I figured out that I was needed to get credentials under jenkins user. For that I just ran this command:</p>

<pre><code>gcloud container clusters get-credentials cluster-1 --zone=my-cluster-zone --project myproject
</code></pre>
