Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-62995

Version 2.11.1 breaking kubernetes deployment somehow

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • snakeyaml-plugin

      Hello. If i am updating this plugin to latest version, then i can't deploy with kubernetes. It's says that can't parse my yaml file. Version 2.10 is working fine

       

      Logs:

      ```

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

      ```

          [JENKINS-62995] Version 2.11.1 breaking kubernetes deployment somehow

          Matti Eiden added a comment -

          kreszka a temporary solution is to downgrade to versions that are known to work. See https://stackoverflow.com/questions/62688901/class-not-found-io-kubernetes-client-openapi-models-v1service 

          Matti Eiden added a comment - kreszka a temporary solution is to downgrade to versions that are known to work. See https://stackoverflow.com/questions/62688901/class-not-found-io-kubernetes-client-openapi-models-v1service  

          Dave Rogers added a comment -

          This bug also breaks the https://plugins.jenkins.io/build-failure-analyzer/  plugin. Downgrading does not resolve the issue

          Dave Rogers added a comment - This bug also breaks the https://plugins.jenkins.io/build-failure-analyzer/   plugin. Downgrading does not resolve the issue

          Matti Eiden added a comment -

          drogers did you downgrade Jackson 2 API? In JENKINS-62214 (assuming it's the same issue you're having) somebody had success by downgrading to 2.10.2 or 2.10.3. I'm running 2.10.2.

          Matti Eiden added a comment - drogers did you downgrade Jackson 2 API? In  JENKINS-62214 (assuming it's the same issue you're having) somebody had success by downgrading to 2.10.2 or 2.10.3. I'm running 2.10.2.

          Matt Sicker added a comment -

          This looks likely related to the snakeyaml plugin specifically, particularly how it handles generic object deserialization safely.

          Matt Sicker added a comment - This looks likely related to the snakeyaml plugin specifically, particularly how it handles generic object deserialization safely.

          Rahul Wagh added a comment - - edited

          Is there any workaround for this in the meantime because I tried downgrading to Jackson 2 API v2.10.0 and Kubernetes Continuous Deploy v2.1.2,

          But i still face this issue - (Any inputs will be highly appreciated and it will save me a lot of time )

           Starting Kubernetes deployment
           Loading configuration: /var/jenkins_home/workspace/test/spring-boot.yml
           ERROR: ERROR: Cannot create property=spec for JavaBean=class V1Deployment {
           apiVersion: apps/v1
           kind: Deployment
           metadata: class V1ObjectMeta {
           annotations: null
           clusterName: null
           creationTimestamp: null
           deletionGracePeriodSeconds: null
           deletionTimestamp: null
           finalizers: null
           generateName: null
           generation: null
           initializers: null
           labels:
          
          {name=jhooq-pod-with-pvc}
          
          managedFields: null
           name: jhooq-pod-with-pvc
           namespace: null
           ownerReferences: null
           resourceVersion: null
           selfLink: null
           uid: null
           }
           spec: null
           status: null
           }
           in 'reader', line 1, column 1:
           apiVersion: apps/v1
           ^
           Cannot create property=containers for JavaBean=class V1DeploymentSpec {
           minReadySeconds: null
           paused: null
           progressDeadlineSeconds: null
           replicas: null
           revisionHistoryLimit: null
           selector: null
           strategy: null
           template: null
           }
           in 'reader', line 8, column 3:
           containers:
           ^
           Unable to find property 'containers' on class: io.kubernetes.client.openapi.models.V1DeploymentSpec
           in 'reader', line 9, column 3:
           - name: jhooq-pod-with-pvc
           ^
          
          in 'reader', line 8, column 3:
           containers:
           ^
          

          Rahul Wagh added a comment - - edited Is there any workaround for this in the meantime because I tried downgrading to Jackson 2 API v2.10.0 and Kubernetes Continuous Deploy v2.1.2, But i still face this issue - (Any inputs will be highly appreciated and it will save me a lot of time ) Starting Kubernetes deployment Loading configuration: / var /jenkins_home/workspace/test/spring-boot.yml ERROR: ERROR: Cannot create property=spec for JavaBean= class V1Deployment { apiVersion: apps/v1 kind: Deployment metadata: class V1ObjectMeta { annotations: null clusterName: null creationTimestamp: null deletionGracePeriodSeconds: null deletionTimestamp: null finalizers: null generateName: null generation: null initializers: null labels: {name=jhooq-pod-with-pvc} managedFields: null name: jhooq-pod-with-pvc namespace: null ownerReferences: null resourceVersion: null selfLink: null uid: null } spec: null status: null } in 'reader' , line 1, column 1: apiVersion: apps/v1 ^ Cannot create property=containers for JavaBean= class V1DeploymentSpec { minReadySeconds: null paused: null progressDeadlineSeconds: null replicas: null revisionHistoryLimit: null selector: null strategy: null template: null } in 'reader' , line 8, column 3: containers: ^ Unable to find property 'containers' on class: io.kubernetes.client.openapi.models.V1DeploymentSpec in 'reader' , line 9, column 3: - name: jhooq-pod-with-pvc ^ in 'reader' , line 8, column 3: containers: ^

          Johannes Dato added a comment - - edited

          Did any workaround work for you rahulwagh or anyone else? I am facing the same issue.

          I've accomplished a manual workaround now utilizing the Kubernetes REST API. This way you can completely ignore the Plugin and simply run a curl in a bash script. In my case I simply needed to redeploy my Kubernetes Deployment which I've done using a service account. If anyone needs detail on this workaround lmk.

          Johannes Dato added a comment - - edited Did any workaround work for you rahulwagh or anyone else? I am facing the same issue. — I've accomplished a manual workaround now utilizing the Kubernetes REST API. This way you can completely ignore the Plugin and simply run a curl in a bash script. In my case I simply needed to redeploy my Kubernetes Deployment which I've done using a service account. If anyone needs detail on this workaround lmk.

          Johannes Dato added a comment - - edited

          So the way that I've worked around it was:

          • Un-installing the plugin
          • Using the Kubernetes Rest API with a service account to redeploy my apps
            Important! You also need to have a yaml in place on the server, which uses the docker image from the local registry.

          After I am done building my application on Jenkins - which results in a new docker image that I want to deploy to Kubernetes - I am using a deployment bash script which looks somewhat like this: 

          # Push new images to local docker registry
          echo "Tagging new image and pushing it to local docker registry.";
          imagename=my-new-built-image;
          localrepository=<kubernetes-master-ip>:5000;
          docker image tag $imagename $localrepository/$imagename;
          
          docker push $localrepository/$imagename;
          
          # Deploy the website service remotely
          echo "Deploying on Kubernetes.";
          timestamp=$(date +%Y-%m-%dT%H:%M:%SZ);
          certificate=<here-goes-your-kubernetes-certificate>;
          body="{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"kubectl.kubernetes.io/restartedAt\":\"${timestamp}\"}}}}}";
          auth="Authorization: Bearer ${certificate}";
          
          curl -g  --request PATCH -d "${body}"  --insecure -H "${auth}" -H "Content-Type: application/strategic-merge-patch+json" -H "Accept: application/json, */*"  https://<kubernetes-master-ip>:6443/apis/apps/v1/namespaces/default/deployments/my-running-deployment?fieldManager=kubectl-rollout
          

          Help:
          How to get a Kubernetes Certificate: for more information on how to setup a Service Account to be able to access the rest api. 

          How to run a local docker registry

          Johannes Dato added a comment - - edited So the way that I've worked around it was: Un-installing the plugin Using the Kubernetes Rest API with a service account to redeploy my apps Important! You also need to have a yaml in place on the server, which uses the docker image from the local registry. After I am done building my application on Jenkins - which results in a new docker image that I want to deploy to Kubernetes - I am using a deployment bash script which looks somewhat like this:  # Push new images to local docker registry echo "Tagging new image and pushing it to local docker registry." ; imagename=my-new-built-image; localrepository=<kubernetes-master-ip>:5000; docker image tag $imagename $localrepository / $imagename ; docker push $localrepository / $imagename ; # Deploy the website service remotely echo "Deploying on Kubernetes." ; timestamp=$(date +%Y-%m-%dT%H:%M:%SZ); certificate=<here-goes-your-kubernetes-certificate>; body= "{\" spec\ ":{\" template\ ":{\" metadata\ ":{\" annotations\ ":{\" kubectl.kubernetes.io/restartedAt\ ":\" ${timestamp}\ "}}}}}" ; auth= "Authorization: Bearer ${certificate}" ; curl -g --request PATCH -d "${body}" --insecure -H "${auth}" -H "Content-Type: application/strategic-merge-patch+json" -H "Accept: application/json, */*" https://<kubernetes-master-ip>:6443/apis/apps/v1/namespaces/default/deployments/my-running-deployment?fieldManager=kubectl-rollout Help: How to get a Kubernetes Certificate : for more information on how to setup a Service Account to be able to access the rest api.  How to run a local docker registry

          Rahul Wagh added a comment -

          Sorry for the late reply but i also found the workaround.

          • I also uninstalled the plugin because it felt there is a lot more to fix if i want to rely on plugin
          • Instead of plugin i used *SSH Pipeline Steps* plugin which i felt more easy to interact because with this plugin i was able to run my kubectl shell command by connecting to kubernetes master node via ssh.

          For more details here I have documented the steps - [https://jhooq.com/ci-cd-jenkins-kubernetes/#87-copy-k8s-spring-boot-deploymentyml-to-k8smaster-server

          jdato probably my blog could help you to answer your question on - How to run a local docker registry?

          Rahul Wagh added a comment - Sorry for the late reply but i also found the workaround. I also uninstalled the plugin because it felt there is a lot more to fix if i want to rely on plugin Instead of plugin i used * SSH Pipeline Steps * plugin which i felt more easy to interact because with this plugin i was able to run my kubectl shell command by connecting to kubernetes master node via ssh. For more details here I have documented the steps - [https://jhooq.com/ci-cd-jenkins-kubernetes/#87-copy-k8s-spring-boot-deploymentyml-to-k8smaster-server jdato probably my blog could help you to answer your question on - How to run a local docker registry ?

          Arpan Mandal added a comment -

          Just FYI ::
          I have so many plugins pipeline to take care, so I can't implement SSH/Rest API based other flow.
          I resolved all the plugin dependences after downgrading the API plugin.

           

          Try these

          https://github.com/sourceshift/JENKINS-62995

           

          Might help some

          Arpan Mandal added a comment - Just FYI :: I have so many plugins pipeline to take care, so I can't implement SSH/Rest API based other flow. I resolved all the plugin dependences after downgrading the API plugin.   Try these https://github.com/sourceshift/JENKINS-62995   Might help some

          Matti Eiden added a comment -

          If you're able to have kubectl installed on your jenkins instance, then the plugin kubernetes-cli is a viable plugin option. Seems to be under active development/maintenance as well, unlike kubernetes-cd.

          Matti Eiden added a comment - If you're able to have kubectl installed on your jenkins instance, then the plugin kubernetes-cli is a viable plugin option. Seems to be under active development/maintenance as well, unlike kubernetes-cd.

            Unassigned Unassigned
            mikkra Mikhail K.
            Votes:
            9 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: