I am trying to setup a pipeline on jenkins that uses docker containers to execute tasks like for example deploy an helm charts using a docker image with helm
here is what my Jenkinsfile looks like
pipeline {
agent none
stages {
stage('Helm') {
agent {
docker { image 'dtzar/helm-kubectl' }
}
steps {
sh '''
helm version
kubectl version
helm ls
kubectl get all -n test
'''
}
}
}
}
but it fails at the helm ls
line because it can not connect to the kubernetes cluster.
How do i connect this pipeline to use the Kubernetes configuration(kubeconfig) i have setup
here is error am getting
+ helm ls
Error: Kubernetes cluster unreachable
I could not find any documentation on how to connect docker pipeline to connect to the kubernetes cluster What do i add to the Jenkinsfile to be able to connect?
UPDATE
i also tried this
pipeline {
agent none
stages {
stage('Helm') {
agent {
docker { image 'dtzar/helm-kubectl' }
}
steps {
withCredentials([kubeconfigContent(credentialsId: 'k8s-cluster', variable: 'KUBECONFIG_CONTENT')]) {
sh '''
helm version
helm ls
kubectl get all -n test
'''
}
}
}
}
}
and got this error
+ helm ls
Error: Kubernetes cluster unreachable
I could not find any documentation on how to connect docker pipeline to connect to the kubernetes cluster
What do i add to the Jenkinsfile to be able to connect?
so seems the docker container is unable to resolve the dns of the kubernetes cluster
how do i resolve this?
kubeconfigId
here is link to the plugin wiki.jenkins.io/display/JENKINS/…