Class not found: io.kubernetes.client.openapi.models.V1Service

Har*_*dio 6 pipeline jenkins kubernetes

I get the following error when trying to use the YAML file from my GitRepo to deploy to kube cluster. 控制台错误

Here is the content of my .yaml file:

apiVersion: v1
kind: Service
metadata:
  name: ts-service
spec:
  type: NodePort
  selector:
    app: ts
  ports:
  - protocol: TCP
    port: 8080
    nodePort: 8080

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ts-deployment
  labels:
    app: ts
spec:
  replicas: 2
  selector:
    matchLabels:
      app: ts
  template:
    metadata:
      labels:
        app: ts
    spec:
      containers:
      - name: ts
        image: $DOCKER_IMAGE_NAME:$BUILD_NUMBER
        ports:
        - containerPort: 8080
Run Code Online (Sandbox Code Playgroud)

I've already tried changing the ports, the API version to apps/v1, etc. What seems weird to me is that no matter which line goes foirst in the file, it always shows me the same issue. What can be causing this?

Har*_*dio 3

我找到了这种行为的根本原因。Jackson 2 API 插件版本 2.11.1 正在破坏 kube 部署;您可以通过以下链接找到更多信息:
https://issues.jenkins-ci.org/browse/JENKINS-62995

降级以下插件对我有用: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

由于这些插件是默认的,您需要在https://plugins.jenkins.io/中找到相关版本的源文件,然后通过
“管理 Jenkins --> 管理插件 --> 高级”将它们上传到您的 Jenkins 服务器。 > 上传插件部分