I cannot resolve an issue that I was stuck with in my beginner tutorial. When I try to create just a deployment on Kubernetes from Jenkins, I got the error message. How can I solve this problem? Could anyone pls help me?
Error
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
^
My Pipeline
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")
}
}
}
}
}
My Deployment yaml from Github (Tested – Working on 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
Source: Ask Javascript Questions
One Reply to “Jenkins – Deploy a Yaml file to Kubernetes from Pipeline Error”
any answer ?