2

I want to deploy helm chart from Jenkins to Kubernetes but I don't find any Plugins in Jenkins for Helm.

How can I tell Jenkins to run Helm chart in Kubernetes ?

2
  • 1
    you can create an docker images with kubectl and helm installed, now you can use this images from jenkins, kind mind to configure helm to access to specific namespace and not to give access to all resources in your cluster
    – c4f4t0r
    Jan 11, 2019 at 12:56
  • Did you try to just run helm install on jenkins? I think that it should work to just run a helm command if jenkins is authenticated to the k8s cluster.
    – 030
    Jan 12, 2019 at 15:35

1 Answer 1

2

Use a docker image within your pipeline that has helm and other tools installed.

To quote the docs:

Pipeline is designed to easily use Docker images as the execution environment for a single Stage or the entire Pipeline. Meaning that a user can define the tools required for their Pipeline, without having to manually configure agents. Practically any tool which can be packaged in a Docker container. can be used with ease by making only minor edits to a Jenkinsfile.

It then gives an example that we can modify to show running helm:

pipeline {
    agent {
        docker { image 'your_image:1.0' }
    }
    stages {
        stage('Deploy') {
            steps {
                sh 'helm list'
            }
        }
    }
}

This is a total game changer. Docker is the plugin to end all plugins. Before Docker you had to find a plug-in written in Java that to exposes a DSL to be scriptable in a Groovy sandbox. That was because it was not secure or scalable to let you simply run your own tools and scripts on a shared Jenkins. You were not even allowed use the full power of Groovy or Java. With Docker it is safe run any script or tools. So you no longer have the indirection of Java plugins and you can use the full power of any Linux tool on any Linux distro.

This approach is exactly how new cloud based build engines work. With bitbucket.com pipelines and cricleci.com you don’t need any plugins. You simply say which containers to use and what commands to run within them just like the example above. The build engine simply checks out the code where the docker container can see it.

Once you have used Docker based builds for a while doing it the old way feels very restricted and limiting. For example consider having to move files around in the build. In a pipeline with Groovy if you are new to Jenkins you have to look at a huge amount of (very ugly) documentation to just to basic things. If you use docker you can simply use standard bash and Linux commands.

4
  • i am using jenkins server on kubernetes meaning jenkins is running as a docker containr...now trying to use this am getting this error Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get what is way around this? how can i allow the daemon socket mounted with kubernetes server without having to manually allow permissions on kubernetes nodes?
    – uberrebu
    Jan 20, 2020 at 12:38
  • am getting this error Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.38/containers/alpine/helm/json: dial unix /var/run/docker.sock: connect: permission denied
    – uberrebu
    Jan 20, 2020 at 12:52
  • @uberrebu: You've been bitten by the inability to run containers inside containers issue. Sorry. Apr 19, 2021 at 22:36
  • Hey @uberrebu, I had a similar issue. I was running jenkins inside a container. This pod has no docker installed. I needed to expose the parent's docker daemon to tcp 0.0.0.0, then go to dashboard -> Configure Clouds, and add a new docker. The address I used to connect from the 'configure cloud' page was 'tcp://172.17.0.1:2375' (my port might be a bit different). It's prob not the safest thing in the world to do but for playing around, it'll work.
    – Killesk
    Oct 31, 2021 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.