connecting jenkins with kubernetes cluster - DeekshithSN/CICD_Java_gradle_application GitHub Wiki
Install Kubernetes Continuous Deploy Plugin, once its installed successfully. goto manage jenkins --> manage credentials --> Click on jenkins global --> add credentials
select
Kind : Kubernetes Configuration
Scope : Global
ID : kubernetes-configs ( any meaningful name )
Kubeconfig : copy the content of kubernetes config file and place it at the file /root/kube/config
in jenkins host
And click OK
and in Jenkinsfile you refer as mentioned below
stage('connecting to k8s cluster'){
steps{
script{
withCredentials([kubeconfigFile(credentialsId: 'kubernetes-config', variable: 'KUBECONFIG')]) {
dir ("kubernetes/"){
sh 'helm list'
sh 'helm upgrade --install --set image.repository="nexus_ip:8083/springapp" --set image.tag="${VERSION}" myjavaapp myapp/ '
}
}
}
}
}