java - Kubernetes Continuous Deploy插件出现问题

标签 java kubernetes jenkins-plugins

使用Kubernetes Continuous Deploy插件将Kubernetes与Jenkins集成时,出现错误。
该插件在Jenkins 2.190.3版之前都可以使用,但是在升级jenkins之后,它开始出现以下错误。
下面的错误看起来像Yaml文件的问题,但是当我手动执行时,yaml文件工作正常。
即使是我也无法降级kubernetes版本。

Jenkins Version : 2.235.2
Kubernetes Continuous Deploy Plugin : 2.3.0
13:19:19 Starting Kubernetes deployment
13:19:19 Loading configuration: /var/jenkins_home/workspace/bom_sso/bom_rs_deployment.yaml
13:19:19 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
13:19:19 in 'reader', line 1, column 1:
13:19:19 apiVersion: apps/v1
13:19:19 ^
13:19:19
13:19:19 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
13:19:19 in 'reader', line 1, column 1:
13:19:19 apiVersion: apps/v1
13:19:19 ^
13:19:19
13:19:19 at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:336)
13:19:19 at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:230)
谢谢,

最佳答案

您描述的问题正在ERROR: ERROR: java.lang.RuntimeException: io.kubernetes.client.openapi.ApiException: Not Found #122 github中讨论,但仍未解决。
这对于使用Jenkins版本的每个人都是非常实际的:2.235.1 +,不确定2.190.3
尚无修复程序,但是有1 workaround,也许会帮助您
我在运行Kubernetes v1.18.3时遇到相同的问题。我正在运行Jenkins v2.235.1,并且我所有的插件都是最新的。

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.

In order to force downgrade those 2 plugins, you can manually delete them from the plugins folder and upload the HPI files directly to Jenkins. Make sure you upload the correct versions as listed above.

This is an ugly workaround, by no means this should be considered a "fix".


  • 降级插件版本

  • jackson 2 API v2.10.0,
    Kubernetes v1.21.3,
    Kubernetes客户端API v4.6.3-1,
    Kubernetes Continuous Deploy v2.1.2,
    Kubernetes凭证v0.5.0
    2)检查DNS是否正常工作(非常重要)
    2a)修改设置,根据需要自定义
    kubectl edit cm coredns -n kube-system
    apiVersion: v1
    data:
      Corefile: |
        eureka cluster.local:53 {
            errors
            health {
               lameduck 5s
            }
            ready
            kubernetes cluster.local in-addr.arpa ip6.arpa {
               pods insecure
               fallthrough in-addr.arpa ip6.arpa
               ttl 30
            }
            prometheus :9153
            forward . /etc/resolv.conf
            cache 30
            loop
            reload
            loadbalance
        }
        .:53 {
            errors
            health {
               lameduck 5s
            }
            ready
            kubernetes cluster.local in-addr.arpa ip6.arpa {
               pods insecure
               fallthrough in-addr.arpa ip6.arpa
               ttl 30
            }
            prometheus :9153
            forward . 8.8.8.8
            cache 30
            loop
            reload
            loadbalance
        }
    kind: ConfigMap
    metadata:
      creationTimestamp: "2020-07-24T21:09:19Z"
      managedFields:
      - apiVersion: v1
        fieldsType: FieldsV1
        fieldsV1:
          f:data: {}
        manager: kubeadm
        operation: Update
        time: "2020-07-24T21:09:19Z"
      - apiVersion: v1
        fieldsType: FieldsV1
        fieldsV1:
          f:data:
            f:Corefile: {}
        manager: kubectl
        operation: Update
        time: "2020-07-27T05:30:57Z"
      name: coredns
      namespace: kube-system
      resourceVersion: "952988"
      selfLink: /api/v1/namespaces/kube-system/configmaps/coredns
      uid: 5a7fc41c-01a7-480a-89bd-82ab3070401c
    
    2b)然后重新启动DNS
    kubectl get pods -n kube-system -oname |grep coredns |xargs kubectl delete -n kube-system
    
    希望对您有帮助

    关于java - Kubernetes Continuous Deploy插件出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63059429/

    相关文章:

    java - linux - 如何运行 selenium-server-standalone?

    java - Scala 类 Gson 库

    docker - 本地领事加入K8s领事Mac

    jenkins - 使用 jenkins 管道插件实现动态并行构建的想法

    java - 连接到 Notes 中的 LDAP 服务器的 SSLHandshakeException

    json - Circe 无法将原始 json 转换为案例类错误 : could not find Lazy implicit value of type io. circe.generic.decoding.DerivedDecoder

    kubernetes - 如何在 kubernetes yaml 文件中使用标签以便系统知道推送了新图像

    jenkins - 通过脚本更改现有 Jenkins 节点上的执行器数量

    Jenkins 管道测试结果分析器支持

    java - 使用同一类的不同版本加载类 : java. lang.LinkageError:尝试为名称重复类定义