Skip to content
A Jenkins Docker image and helm chart for running in Kubernetes
Dockerfile Groovy Smarty
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
helm/jenkins-k8s Add missing selector section Aug 27, 2019
Dockerfile 1. Update to Jenkins LTS as of 2019/08/27 Aug 27, 2019
Vagrantfile Add Vagrantfile as an option to test your work with vagrant Feb 12, 2018
security.groovy Initial commit Feb 11, 2018

Jenkins in Kubernetes

This repository has a Dockerfile and a helm chart for setting up a simple Jenkins master for running in Kubernetes.

This Jenkins has the required tools to work in and with Kubernetes

  • Jenkins application with pre-loaded plugins (see plugins.txt)
  • Skipped setup wizard
    • You can control admin user and password with --set adminUser=${USER},adminPassword=${PASSWORD}
    • You can add and remove plugins by editing the plugins.txt file
  • Docker for managing a Docker CI lifecycle
  • kubectl command line client for working with the Kubernetes API
  • helm for managing your helm charts CI/CD lifecycle

IMPORTANT: This example is for demo and testing. It should not be used a production environment!

Get the example Docker image

You can pull an already built version of this Jenkins image from

# Pull the image
$ docker pull

Build the Jenkins Docker image

You can build the image yourself


# Build the image
$ docker build -t ${DOCKER_REG}/jenkins:lts-k8s .

# Push the image
$ docker push ${DOCKER_REG}/jenkins:lts-k8s

Test your image

You can run your container locally, if you have Docker installed

  • Using the pre-built image
# Run the container you built before
$ docker run -d --name jenkins -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock
  • Using your built image
# Run the container you built before
$ docker run -d --name jenkins -p 8080:8080 -v /var/run/docker.sock:/var/run/docker.sock ${DOCKER_REG}/jenkins:lts-k8s

Deploy Jenkins helm chart to Kubernetes

If you are using the pre-built image, you can install the helm chart with

# Init helm and tiller on your cluster
$ helm init

# Deploy the Jenkins helm chart
# (same command for install and upgrade)
$ helm upgrade --install jenkins ./helm/jenkins-k8s

NOTE: This helm chart deploys a pod with two containers. One for the Docker daemon and another for Jenkins. This is based on the suggestion in

If you are building your own version of Jenkins, you need your Kubernetes cluster to be able to pull the Docker image. You have to create a Docker registry secret and reference to it in your helm install command.

# Create a Docker registry secret

$ kubectl create secret docker-registry docker-reg-secret \
        --docker-server=${DOCKER_REG} \
        --docker-username=${DOCKER_USR} \
        --docker-password=${DOCKER_PWD} \

# Deploy the Jenkins helm chart
# (same command for install and upgrade)
$ helm upgrade --install jenkins \
        --set imagePullSecrets=docker-reg-secret \
        --set image.repository=${DOCKER_REG}/jenkins \
        --set image.tag='lts-k8s' \

Data persistence

By default, in Kubernetes, the Jenkins deployment uses a persistent volume claim that is mounted to /var/jenkins_home. This assures your data is saved across crashes, restarts and upgrades.


You can test your Docker image using Vagrant. The enclosed Vagrantfile will provision an Ubuntu VM with Docker.

  • Spin up the Vagrant VM then build and run the Docker image
# Spin up the Vagrant VM
$ vagrant up

# SSH into the VM
$ vagrant ssh

# Go to the mounted sources repository
$ cd /opt/provisioning

# Build and run your Jenkins container as shown above
You can’t perform that action at this time.