A single, monolithic Jenkins install works great for small teams with only a few projects. But as a their needs grow, they will need to scale up their Jenkins environment. Jenkins slaves provide a great way to scale a Jenkins ecosystem by providing worker nodes to handle the execution of jobs, while the Jenkins master acts as a control node. In this lesson, you will learn what Jenkins slaves are, and you will also see a demonstation of how to create one.
You can find more information on Jenkins slaves here:
Here are the commands used in this lesson's demo. They were run on the slave node:
sudo yum -y install git java-1.8.0-openjdk sudo useradd -d /var/lib/jenkins jenkins ssh-keygen
ssh-keygen prompts you, just hit enter for each one to select the defaults.
Next, read the file with the public key and copy its contents to your clipboard:
Now we've got to make a .ssh directory for the jenkins user, and create an autorized_keys file in there:
sudo mkdir /var/lib/jenkins/.ssh sudo vi /var/lib/jenkins/.ssh/authorized_keys
Paste the contents of id_rsa.pub into authorized_keys and save the file.
We created the directory and file with sudo, and jenkins is who needs to actually own it. Lets' fix that:
sudo chown -R jenkins:jenkins /var/lib/jenkins/.ssh
Now, we the contents of the file with private key:
Copy the contents of id_rsa (the private key) so that you can paste them into Jenkins as a credential. Finish setting up the slave by adding it via the Jenkins UI.