Kubernetes持续部署插件存在问题。

huangapple 未分类评论44阅读模式
英文:

Kubernetes Continuous Deploy Plugin having issues

问题

以下是翻译好的内容:

在将Kubernetes与Jenkins集成并使用Kubernetes Continuous Deploy插件时,我遇到了以下错误。

这个插件在Jenkins版本2.190.3之前的版本中运行良好,但在升级Jenkins后,开始出现以下错误。

下面的错误看起来像是与Yaml文件有关的问题,但是当我手动执行该yaml文件时,它能够正常工作。

甚至我也无法降级Kubernetes版本。

Jenkins版本:2.235.2
Kubernetes Continuous Deploy插件:2.3.0
13:19:19 开始Kubernetes部署
13:19:19 加载配置:/var/jenkins_home/workspace/bom_sso/bom_rs_deployment.yaml
13:19:19 错误:错误:无法为标签构造Java对象:yaml.org,2002:io.kubernetes.client.openapi.models.V1Deployment;异常=找不到类:io.kubernetes.client.openapi.models.V1Deployment
13:19:19 在'reader',第1行,第1列:
13:19:19 apiVersion: apps/v1
13:19:19 ^
13:19:19
13:19:19 hudson.remoting.ProxyException:无法为标签构造Java对象:yaml.org,2002:io.kubernetes.client.openapi.models.V1Deployment;异常=找不到类:io.kubernetes.client.openapi.models.V1Deployment
13:19:19 在'reader',第1行,第1列:
13:19:19 apiVersion: apps/v1
13:19:19 ^
13:19:19
13:19:19 在org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:336)处
13:19:19 在org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:230)处

谢谢,

英文:

I am getting below error while intergrating Kubernetes with Jenkins using Kubernetes Continuous Deploy Plugin.

This is plugin worked till Jenkins Version 2.190.3 but after upgrading jenkins its started giving below error.

Below error looks like issue with Yaml file but the yaml file working fine when I executed manually.

Even I am not able to downgrade the kubernetes version.

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)

Thanks,

答案1

得分: 0

你所描述的问题正在此链接中讨论,涉及错误:java.lang.RuntimeException: io.kubernetes.client.openapi.ApiException: Not Found #122,目前仍未解决。

这对于使用 Jenkins 版本:2.235.1+ 的所有人来说都很实际,不确定 2.190.3 是否适用。

尽管尚无修复措施,但有一个解决方法,或许可以帮助你。

我在运行 Kubernetes v1.18.3,Jenkins v2.235.1,以及所有插件均已更新的环境中遇到了相同的问题。

我目前找到的解决方法是将 Jackson 2 API 降级到 v2.10.3,将 Snakeyaml API 降级到 v1.26.2。如果这两个插件更新到了各自的最新版本,错误消息会再次出现。

要强制降级这两个插件,你可以从插件文件夹中手动删除它们,然后将 HPI 文件直接上传到 Jenkins。确保上传的版本与上面列出的版本相匹配。

尽管这是一个不太美观的解决方法,但绝不应被视为“修复”。

  1. 降级插件版本
  • Jackson 2 API v2.10.0
  • Kubernetes v1.21.3
  • Kubernetes Client API v4.6.3-1
  • Kubernetes Continuous Deploy v2.1.2
  • Kubernetes Credentials v0.5.0
  1. 检查 DNS 是否正常工作(非常重要)
    2a) 检查设置,根据需要进行自定义

    运行命令:kubectl edit cm coredns -n kube-system
    apiVersion: v1
    data:
      Corefile: |
        eureka cluster.local:53 {
            // ...(此处省略部分配置)
        }
    kind: ConfigMap
    metadata:
      // ...(此处省略部分元数据)
    

    2b) 然后重新启动 DNS

    运行命令:kubectl get pods -n kube-system -oname |grep coredns |xargs kubectl delete -n kube-system
    

希望这能对你有所帮助。

英文:

The issue you described is discussing in the ERROR: ERROR: java.lang.RuntimeException: io.kubernetes.client.openapi.ApiException: Not Found #122 github and still non-resolved.

This is very actual for everyone who use Jenkins Version : 2.235.1 +, not sure about 2.190.3

There are no fixes yet, however there is 1 workaround, maybe in will help you

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.
>
> 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".

  1. Downgrade plugins version

Jackson 2 API v2.10.0,

Kubernetes v1.21.3,

Kubernetes Client API v4.6.3-1,

Kubernetes Continuous Deploy v2.1.2,

Kubernetes Credentials v0.5.0

2)Check dns working properly (very important)
2a)Revise settings, customize as needed

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)Then restart dns

kubectl get pods -n kube-system -oname |grep coredns |xargs kubectl delete -n kube-system

Hope that will help you

答案2

得分: 0

感谢VKR,

但幸运的是,在Jenkins 2.235.3版本中已经修复了这个问题。

以下是我的配置。

Jenkins版本:2.235.3

谢谢,

英文:

Thanks VKR,

But luckily it fixed in the Jenkins 2.235.3 version.

Below are the configuration I have.

Jenkins version : 2.235.3

Thanks,

huangapple
  • 本文由 发表于 2020年7月24日 00:58:05
  • 转载请务必保留本文链接:https://java.coder-hub.com/63059429.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定