![](/img/trans.png)
[英]How can I generate a `V1Job` object for the Kubernetes nodejs API client from a yaml file?
[英]Jenkins - Deploy a Yaml file to Kubernetes from Pipeline Error
我無法解決我在初學者教程中遇到的問題。 當我嘗試從 Jenkins 在 Kubernetes 上創建一個部署時,我收到了錯誤消息。
根據我的研究,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插件。 我不知道我該怎么做?
我怎么解決這個問題? 任何人都可以幫助我嗎?
錯誤
Starting Kubernetes deployment
Loading configuration: /var/lib/jenkins/workspace/k8sdeploy/k8sdeploy.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
^
我的管道
pipeline {
agent any
stages {
stage('Clone App from Github') {
steps {
git credentialsId: 'github', url: 'https://github.com/eneslanpir/k8sdeploy'
}
}
stage("Wait For 5 Seconds"){
steps {
sleep 5
}
}
stage("Kubernetes Create Deployment"){
steps{
script {
kubernetesDeploy(configs: "k8sdeploy.yml", kubeconfigId: "kubeconfig")
}
}
}
}
}
我的 Github 部署 yaml(已測試 - 在 Kuberentes 上工作)
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment-jenkins
spec:
selector:
matchLabels:
app: nginx
replicas: 1
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx-jenkins
image: nginx:1.16.1
ports:
- containerPort: 80
當降級到 Jackson 2 API v2.10.0 時,一切都會出錯。
我通過嘗試下面鏈接中的插件解決了這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.