Child pages
  • Kubernetes Plugin
Skip to end of metadata
Go to start of metadata

This plugin allows Jenkins agents to be dynamically provisioned on a Kubernetes cluster.

Plugin Information

View Kubernetes on the plugin site for more information.


The aim of the Kubernetes plugin is to be able to use a Kubernetes cluster to dynamically provision a Jenkins agent (using Kubernetes scheduling mechanisms to optimize the loads), run a single build, then tear-down that agent.


A quick setup is :

- get a Kubernetes cluster running

- use a docker image for the agents, or create your own

Kubernetes Environment

Follow the getting started guide on Kubernetes or use Google Kubernetes Engine.

Docker image for Agents

You can find ready-made Docker images for Jenkins agents using jnlp at jenkins/jenkins-slave.

The images can be customized to fit your needs.


Refer to the README in the plugin repository


Refer to the CHANGELOG in the plugin repository

Issue Tracker

Can be found HERE


  1. One the things that I am confused about (and I suspect others might be as wel)

    What are the requirements for the Jenkins Master to manage Kubernetes. I assume it needs the kubectl command installed?

    If Jenkins is itself running on K8S, is there a Jenkins image that has the requirements?

    1. no need for kubectl, the jenkins/jenkins image will do

  2. Having followed the setup instructions precisely, Kubernetes is spinning up slave containers that die with "connect timed out" errors when they try to JNLP connect back to my Jenkins master. Is there some additional network configuration necessary to get the slave containers to talk to the master?

    1. Brett,

      I presume you would have JNLP port disabled. You have go to "Manage Jenkins > Configure Global Security", and enable either specify a "Fixed" port or a "Random" port(in case it is "Disabled").

  3. Can different Jenkins masters use the same Kubernetes cluster?

    1. Yes. Kubernetes is inherently multi-tenant.

      To facilitate ease of management, consider running your various Jenkins masters (and their associated spawned agent pods) in dedicated namespaces within the shared cluster.

  4. j u

    What's the best practice for how one would build docker images from within these jenkins slaves?

    1. Depends on what you are looking for regarding "best", but "Docker outside of Docker" pattern will work:

  5. I'm not sure I follow the nesting pod templates section of the user guide. What docker image is actually used when you nest the pod templates? In the examples, each pod template specifies a docker image to use (one pod uses a maven-enabled image, the other uses a docker-enabled image) - in what container are the ```sh``` steps executed, and how are the dual requirements (ability to execute docker and maven commands) met in a single container?

  6. Hai jenkinsci/jnlp-slave

    1. Then you will need to build the JNLP agent into your docker image.

      1. i builded my image taking base image as

        in my dockerfile From jenkinsci/jnlp-slave

  7. Hi. The config option "Max number of instances" is not working as I expect. I have two pod templates, one is configured with 2 max instances and the other one with 6 max instances. The "Container Cap" is set to 8 but for example the podtemplate configured with 2 max instances is creating 3 or 4 instances. Am i doing something wrong?

    1. I'm seeing same issue. I set this number to 10 but actually 20+ containers are launched. This number has worked before, is this a regression?

  8. I found one thing that is really bad, that when a pod is created it sets these labels on all slaves that are created:

    Labels: jenkins=slave

    What I would like is that it sets it to a unique value as it does when deploying something normally on kubernetes:

    Labels: pod-template-hash=380424406


    Not having a unique label will cause problems if you need to expose services, f.ex if you have function tests and hardware running outside the cluster. If multiple pods have SAME labels and you run the kubectl expose command it will use the labels as selectors resulting in multiple endpoints which is not what you want.

    It would be nice to have something like this instead:


    Labels: jenkins-slave-hash=<unique/random hash>




  9. Hello.


    I am k8s newbie. Is there an example use case? Or can you guide how to use this ?

    I am setting kubenetes cluster (3 servers for example) using kubeadm.

    But I have no idea for next steps... 


    In my case, I have one dedicated jenkins master server, I want to use kubernetes for agents. But I don't know how to do.

    Thank you.

Write a comment…