<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>I updated my Kubernetes version from 1.5 to 1.9, when i force the Kubectl command, does work, just by Jenkis doesn't, as you request follow my k8sdeploy.yaml</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: cbbox
  labels: 
    app: cbbox  
spec:
  replicas: 1
  selector: 
     matchLabels:
       app: cbbox 
  template:
    metadata:
      labels:
        app: cbbox
    spec:
      containers:      
      - image: myregistryrepository
        name: cbbox
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
        env:
          - name: SECRET_DB_IP
            valueFrom:
              secretKeyRef:
                name: cbboxsecret
                key: SECRET_DB_IP
          - name: SECRET_DB_PASSWORD
            valueFrom:
              secretKeyRef:
                name: cbboxsecret
                key: SECRET_DB_PASSWORD
          - name: SECRET_DB_USER
            valueFrom:
              secretKeyRef:
                name: cbboxsecret
                key: SECRET_DB_USER
          - name: SECRET_LDAP_DOMAIN
            valueFrom:
              secretKeyRef:
                name: cbboxsecret
                key: SECRET_LDAP_DOMAIN
          - name: SECRET_LDAP_URLS
            valueFrom:
              secretKeyRef:
                name: cbboxsecret
                key: SECRET_LDAP_URLS
          - name: SECRET_LDAP_BASE_DN
            valueFrom:
              secretKeyRef:
                name: cbboxsecret
                key: SECRET_LDAP_BASE_DN
          - name: SECRET_TIME_ZONE
            valueFrom:
              secretKeyRef:
                name: cbboxsecret
                key: SECRET_TIME_ZONE
      imagePullSecrets:
        - name: acrcredentials
---
apiVersion: v1
kind: Service
metadata:
  name: cbbox
spec: 
  type: LoadBalancer
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080
  selector:
    app: cbbox
</code></pre>
