Skip to content
This repository has been archived by the owner on Mar 11, 2022. It is now read-only.

Jenkins plugin that provides an elastic pool of slaves, using Docker containers, that live only as long as the job.

License

Notifications You must be signed in to change notification settings

kmbulebu/docker-ephemeral-cloud

Repository files navigation

Docker Ephemeral Cloud plugin

Build Status

Introduction

Ensuring Jenkins has a reliable, scalable, and flexible job slaves is a challenge. The Docker Ephemeral Cloud plugin provides an elastic pool of slaves, using Docker containers, that live only as long as the job.

Motivations

  • Elastic slaves. An executor pool that scales to demand.
  • Perfect isolation. Builds are always executed in a clean environment, isolated from others.
  • Low maintenance. No always-on slaves to maintain.
  • Easy build environments. Environments packaged and shared as Docker images.
  • Focus on builds and stateless jobs.

How it works

When a job is scheduled, Jenkins checks for Docker image configurations that match the labels of the job. When one is found, Docker is invoked via REST APIs to pull the image and run the container. Within the container, the Jenkins JNLP slave jar is downloaded and run. Communication is established to the Jenkins master and the new slave node performs the requested job. When complete, the container is stopped and removed.

Features

  • Use Docker containers as Jenkins slaves.
  • No open ports required. Containers 'phone home' via Jenkins JNLP slave connections.
  • Supports multiple Docker images using slave label mappings.
  • Connect via UNIX socket or remotely over REST. TLS supported.
  • Completely stateless. One executor, one job run per container life.

Using

Prerequisites

Jenkins prerequisites

  • Recommend Jenkins 1.609.3 or newer.
  • Jenkins URL is correctly set in global configuration.
  • JNLP slave ports are enabled and open.

Docker prerequisites

  • Recommend Docker 1.7+
  • Docker is configured and able to access the registries hosting the images.
  • Recommend using TCP + TLS for secure, remote communication.
  • Containers can reach the Jenkins master via the JNLP port.

Image prerequisites

  • Contains a Java install compatible with Jenkins with java on the path. Used for invoking Jenkins slave jar.
  • Contains curl, on the path. Used for downloading the slave jar

Configuring

  1. Add a Docker Ephemeral Cloud configuration in your Jenkins global configuration. ![Cloud Configuration] (cloud_config.png)

  2. Add a Docker image to use as a base for slave containers. ![Image Configuration] (image_basic_config.png)

  3. Run a job. You will see slaves come move through various states as they create, run, and destroy. ![Build executors] (build_executors.png)

Known issues and workarounds

  • Slaves no longer able to connect via JNLP or see deadlocked threads in node provisioning: You may be encountering JENKINS-24155. Set system property -Djenkins.slaves.NioChannelSelector.disabled=true as a workaround.

  • Jenkins too slow to request new slaves: Try setting system property -Dhudson.model.LoadStatistics.clock=10000 to smaller values to instruct Jenkins to calculate the need for slaves more often. 10000 is the default.

  • Docker Ephemeral Cloud plugin is built using Spotify's docker-client library. Please see their issues page for possible limitations and known issues.

Thanks

Special thanks to Spotify and other contributors to docker-client. The docker-client library is clean and intuitive, making this project a pleasure to write.

About

Jenkins plugin that provides an elastic pool of slaves, using Docker containers, that live only as long as the job.

Resources

License

Stars

Watchers

Forks

Packages

No packages published