kubernetes-cd-plugin: io.kubernetes.client.openapi.models.V1Deployment Class not found exception

This seems to have started after a kubernetes 1.16 -> 1.17 cluster upgrade. We don’t have a lot of jobs using this cd plugin yet, so we didn’t notice right away.

19:14:55  ERROR: ERROR: Can't construct a java object for tag:yaml.org,2002:io.kubernetes.client.openapi.models.V1Deployment; exception=Class not found: io.kubernetes.client.openapi.models.V1Deployment
19:14:55   in 'reader', line 1, column 1:
19:14:55      apiVersion: apps/v1

The class file exists, and there doesn’t seem to be another plugin which has an older version of the kubernetes client jar.

$ find plugins -name \*.jar -print | while read i; do jar -tf "$i" | grep -q io.kubernetes.client.openapi.models && echo "$i" ; done
plugins/kubernetes-cd/WEB-INF/lib/client-java-api-7.0.0.jar
$ jar -tf plugins/kubernetes-cd/WEB-INF/lib/client-java-api-7.0.0.jar | grep io.kubernetes.client.openapi.models.V1Deployment
io/kubernetes/client/openapi/models/V1Deployment.class
io/kubernetes/client/openapi/models/V1DeploymentBuilder.class
io/kubernetes/client/openapi/models/V1DeploymentCondition.class
...

Full Error:

19:14:51  Starting Kubernetes deployment
19:14:55  Loading configuration: /var/lib/jenkins/workspace/internal-api-docs/docs/internal_api/deployment.yaml
19:14:55  ERROR: ERROR: Can't construct a java object for tag:yaml.org,2002:io.kubernetes.client.openapi.models.V1Deployment; exception=Class not found: io.kubernetes.client.openapi.models.V1Deployment
19:14:55   in 'reader', line 1, column 1:
19:14:55      apiVersion: apps/v1
19:14:55      ^
19:14:55  
19:14:55  hudson.remoting.ProxyException: Can't construct a java object for tag:yaml.org,2002:io.kubernetes.client.openapi.models.V1Deployment; exception=Class not found: io.kubernetes.client.openapi.models.V1Deployment
19:14:55   in 'reader', line 1, column 1:
19:14:55      apiVersion: apps/v1
19:14:55      ^
19:14:55  
19:14:55  	at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:336)
19:14:55  	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:230)
19:14:55  	at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:219)
19:14:55  	at io.kubernetes.client.util.Yaml$CustomConstructor.constructObject(Yaml.java:337)
19:14:55  	at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:173)
19:14:55  	at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:157)
19:14:55  	at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:472)
19:14:55  	at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:438)
19:14:55  	at io.kubernetes.client.util.Yaml.loadAs(Yaml.java:224)
19:14:55  	at io.kubernetes.client.util.Yaml.modelMapper(Yaml.java:494)
19:14:55  	at io.kubernetes.client.util.Yaml.loadAll(Yaml.java:272)
19:14:55  	at com.microsoft.jenkins.kubernetes.wrapper.KubernetesClientWrapper.apply(KubernetesClientWrapper.java:236)
19:14:55  	at com.microsoft.jenkins.kubernetes.command.DeploymentCommand$DeploymentTask.doCall(DeploymentCommand.java:172)
19:14:55  	at com.microsoft.jenkins.kubernetes.command.DeploymentCommand$DeploymentTask.call(DeploymentCommand.java:124)
19:14:55  	at com.microsoft.jenkins.kubernetes.command.DeploymentCommand$DeploymentTask.call(DeploymentCommand.java:106)
19:14:55  	at hudson.FilePath.act(FilePath.java:1162)
19:14:55  	at com.microsoft.jenkins.kubernetes.command.DeploymentCommand.execute(DeploymentCommand.java:68)
19:14:55  	at com.microsoft.jenkins.kubernetes.command.DeploymentCommand.execute(DeploymentCommand.java:45)
19:14:55  	at com.microsoft.jenkins.azurecommons.command.CommandService.runCommand(CommandService.java:88)
19:14:55  	at com.microsoft.jenkins.azurecommons.command.CommandService.execute(CommandService.java:96)
19:14:55  	at com.microsoft.jenkins.azurecommons.command.CommandService.executeCommands(CommandService.java:75)
19:14:55  	at com.microsoft.jenkins.azurecommons.command.BaseCommandContext.executeCommands(BaseCommandContext.java:77)
19:14:55  	at com.microsoft.jenkins.kubernetes.KubernetesDeploy.perform(KubernetesDeploy.java:42)
19:14:55  	at com.microsoft.jenkins.azurecommons.command.SimpleBuildStepExecution.run(SimpleBuildStepExecution.java:54)
19:14:55  	at com.microsoft.jenkins.azurecommons.command.SimpleBuildStepExecution.run(SimpleBuildStepExecution.java:35)
19:14:55  	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
19:14:55  	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
19:14:55  	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
19:14:55  	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
19:14:55  	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
19:14:55  	at java.lang.Thread.run(Thread.java:748)
19:14:55  Caused by: hudson.remoting.ProxyException: org.yaml.snakeyaml.error.YAMLException: Class not found: io.kubernetes.client.openapi.models.V1Deployment
19:14:55  	at org.yaml.snakeyaml.constructor.Constructor.getClassForNode(Constructor.java:664)
19:14:55  	at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.getConstructor(Constructor.java:322)
19:14:55  	at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:331)
19:14:55  	... 30 more

About this issue

Commits related to this issue

Most upvoted comments

I have the same problem running Kubernetes v1.18.3. I’m running Jenkins v2.235.1 and all my plugins are up to date.

The workaround I’ve found for now is to downgrade Jackson 2 API to v2.10.3 and to downgrade Snakeyaml API to v1.26.2. If those 2 plugins are updated to their respective latest versions, the error message comes back.

I have found the solution to this problem. I have tried many times and it’s working perfectly. Kubernetes CD plugin should be Version 1.0. No need to downgrade other plugins.

Downgrading plugins worked for me too. I’m running clean Jenkins v2.254 with recommended plugins and latest Kubernetes Continuous Deploy Plugin (2.3.0) and have same error. After downgrading:

  • Jackson 2 API 2.11.2 -> 2.10.3
  • Snakeyaml API 1.26.4 -> 1.26.3
  • Kubernetes Client API 4.9.2-2 -> 4.9.2-1
  • Kubernetes Credentials 0.7.0 -> 0.6.2

all works fine! Also, i downgraded ECharts API and JUnit, but this plugins not required for kubernetes cd. Thanks

Hi @nguyenminh15988 ,

Kindly hit this link to download version 1.0.0 .hpi file of Kubernetes cd plugin.

Reference - https://plugins.jenkins.io/kubernetes-cd/#releases

Has anyone been able to find the root cause for this? I’m the maintainer of another Jenkins plugin (vrealize-automation-8) that suffers from the exact same issue. I’d love to find a way to fix my code instead of having users downgrade plugins. https://issues.jenkins.io/browse/JENKINS-64498

Check this thread in StackOverflow https://stackoverflow.com/questions/62688901/class-not-found-io-kubernetes-client-openapi-models-v1service/68437162#68437162

The solution is just to downgrade the plugin Kubernetes Continuous Deploy to 1.0

I’ve changed the plugin, I started to use this one https://plugins.jenkins.io/kubernetes-cli simple to integrate and works fine 😉

I have found the solution to this problem. I have tried many times and it’s working perfectly. Kubernetes CD plugin should be Version 1.0. No need to downgrade other plugins.

it worked for me too. thank you

Hey @braunly thanks for the solution!

Also, i downgraded ECharts API and JUnit, but this plugins not required for kubernetes cd.

Please could you also provide the versions of these plugins which you downgraded to? Cheers

Any update ?