<p>When I try to build a new image to Kubernetes, I got this error:</p>
<blockquote>
<p><code>**unable to decode &quot;K8sDeploy.yaml&quot;: no kind &quot;Deployment&quot; is registered for version &quot;apps/v1&quot;** </code></p>
</blockquote>
<p>Thie error began when I updated the Kubernetes version, here my version info:</p>
<pre><code>Client Version: v1.19.2
Server Version: v1.16.13
</code></pre>
<p><a href="https://i.stack.imgur.com/2uRGJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2uRGJ.jpg" alt="enter image description here" /></a></p>
<p>I tried also to build by my localhost and does work, but by Jenkins don't.</p>
<p>Somebody knows to solve this?</p>

Gabriel Aguiar
<p>To check what <code>apiVersion</code> supports a <code>Deployment</code> resource in your <strong>kubernetes</strong> cluster you may run:</p>
<pre><code>$ kubectl explain deployment | head -2
</code></pre>
<p>and you can be almost sure that the result will be as follows:</p>
<pre><code>KIND:     Deployment
VERSION:  apps/v1
</code></pre>
<p>All modern <strong>kubernetes</strong> versions use <code>apps/v1</code>, which was available since <code>v1.9</code>, so for quite a long time already. As you may see <a href="https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/" rel="nofollow noreferrer">here</a>, older versions which were still available in <strong>kubernetes</strong> <code>1.15</code> have been deprecated in <code>1.16</code>.</p>
<blockquote>
<p>Client Version: v1.19.2 Server Version: v1.16.13</p>
</blockquote>
<p>As stated above, in <strong>kubernetes</strong> <code>1.16</code>, <code>Deployment</code> <strong>must use</strong> <code>apps/v1</code> and there is no possibility to use older api versions like <code>extensions/v1beta1</code>, <code>apps/v1beta1</code> or <code>apps/v1beta2</code> which were still avilable in <code>1.15</code>.</p>
<p>Your issue seems to me rather an error from <strong>Jenkins</strong> (possibly old version of <strong>Jenkins</strong> itself or <strong>some of its plugins</strong> or perhaps something with its configuration) which is not able to recognize/parse the correct (and currently required) <code>apiVersion</code> for <code>Deployment</code> resource.</p>
<p>For troubleshooting purpose you can try and change the <code>apiVersion</code> to one of the listed above. This should give you a different error (this time from kubernetes API server) as in <code>1.16</code> it won't be able to recognize it.</p>
<p>But at least it should give you a clue. If with older <code>apiVersion</code> your <strong>Jenkins</strong> doesn't complain any more, it would mean that it is set to work with older API versions and an update may help.</p>
<p>I see you filed an <a href="https://github.com/kubernetes/website/issues/24888" rel="nofollow noreferrer">issue</a> on <strong>kubernetes GitHub</strong> so let's wait what they say, but as I said before to me it doesn't look like an issue with <strong>kubernetes</strong> but rather with <strong>Jenkins</strong> ability to parse a legitimate <code>Deployment</code> <code>yaml</code>.</p>
