Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

Allow multiple masters to share a node that is defined as a resource on a Foreman instance.

Wiki Markup
{jenkins-plugin-info:pluginId=foreman-node-sharing}

Table of Contents
maxLevel4
minLevel1
printablefalse

Essentials

  • This plugin provides a means to automatically coordinate the sharing of bare metal resources as nodes amongst among multiple masters.
  • It connects to a single Foreman instance and communicates multiple Jenkins masters reserve it communicating via the Foreman Reserve Plugin API.
  • Resource Disposer plug-in (not released yet) is used for releasing nodesOnce configured, Jenkins is able to reserve hosts based on labels attached to them and the labels builds require.
    • It will behave just any other Jenkins Cloud.
  • Nodes are connected over SSH using the same credential.
  • To ensure fairness, hosts will be utilized for a single build only and returned back to pool for other masters to reserve.

Set Up

Configure resource in Foreman

This plugin will

  • Login to the Foreman instance
  • Navigate to Hosts / New Host
  • Populate the following properties
    • Name
    • Domain
    • IP Address
  • Add the following properties:
    • JENKINS_LABEL
    • JENKINS_SLAVE_REMOTEFS_ROOT
    • RESERVED
  • Set the JENKINS_LABEL property to be the set of labels that this resources provides. Separate mulitple labels by a space.
  • Set the JENKINS_SLAVE_REMOTEFS_ROOT property to be the value of the REMOTEFS_ROOT for this shared node.

...

Cloud in Jenkins(es)

  • Once the plugin is installed, a cloud type called Foreman Shared Node is made available.
  • Navigate to Manage Jenkins / Configure Jenkins / Cloud
  • Click on Add a new cloud
  • Select Foreman Shared Node

Image Added

  • Enter the Foreman connection details

Image Added

  • Click Test Connection to verify the Foreman connection details.
    • The plugin will report the version of Foreman.
  • Click Save.

Hosts in Foreman

Automatically

TODO: Document new inventory population tool.

There is a script that can be used to populate many resources in Foreman. See https://raw.githubusercontent.com/scoheb/acceptance-test-harness/f1f426b171538373d92e69afa278a0288bf9b017/src/test/resources/foreman_node_sharing_plugin/setup.sh

Usage: setup.sh URL HOSTNAME IP LABEL

...

Manually

  • Once the plugin is installed, a cloud type called Foreman Shared Node is made available.Login to the Foreman instance
  • Navigate to Manage Jenkins / Configure Jenkins / Cloud
  • Click on Add a new cloud
  • Select Foreman Shared Node

Image Removed

  • Enter the Foreman connection details

Image Removed

  • Click on Test Connection to verify the Foreman connection details.
    • The plugin will report the version of Foreman.
  • Click on Check for Compatible Foreman Hosts. You should see the hosts you have configured in Foreman:

Image Removed

  • Add or select the credentials needed to connect via SSH to your resources in Foreman.
  • Click on Save.

Job Setup

  • Simply enter the desired label in the job configuration and Jenkins will attempt to provision the node for youHosts / New Host
  • Populate the following properties
    • Name
    • Domain
    • IP Address
  • Add the following properties:
    • JENKINS_LABEL
    • JENKINS_SLAVE_REMOTEFS_ROOT
    • RESERVED
  • Set the JENKINS_LABEL property to be the set of labels that this resources provides. Separate mulitple labels by a space.
  • Set the JENKINS_SLAVE_REMOTEFS_ROOT property to be the value of the REMOTEFS_ROOT for this shared node.

Internal workings

Build sequence

  • A job with label myLabel is triggered and placed in Jenkins queue.
  • Jenkins Cloud API checks to see if a slave exists with label myLabel
  • If not, all defined Clouds are checked to see which one can provision label myLabel
  • The plugin is requested to provision and performs:
    • Foreman query to search for an UN-RESERVED host that has the parameter where JENKINS_LABEL = matches myLabel
    • Foreman API call to reserve host
      • The Jenkins URL will be added as the RESERVED property value.
    • Foreman query to obtain Jenkins RemoteFS Root for the host
  • Node is created and SSH Connection established using defined Cloud credentials.
  • Build is performed on newly provisioned slave.
  • The plugin immediately attempts to terminate the node and calls Foreman API to release the resource.

...