100 Days of DevOps — Day 61-Jenkins Agent Node
To view the updated DevOps course(101DaysofDevOps)
Course Registration link: https://www.101daysofdevops.com/register/
Course Link: https://www.101daysofdevops.com/courses/101-days-of-devops/
YouTube link: https://www.youtube.com/user/laprashant/videos
Welcome to Day 61 of 100 Days of DevOps, Focus for today is Jenkins Agent Node
Yesterday I showed you how to set up Jenkins Server
The above setup works great in a small environment but as your team grows you need to scale up your Jenkins and in those situations, you need Master/Agent setup. In Master/Agent setup, Master acts as a control node and Jenkins with the agent installed to take care of the execution of all the jobs.
Requirement
- Jenkins Master
- Agent Node
NOTE: I am performing all the steps on Centos7
Step1: Install the necessary package on the agent node
yum -y install java-1.8.0-openjdk git
- In this case, I am installing java and git
- You don’t Jenkins rpm package on the agent machine
Step2: Create user and copy the ssh key from Master to agent node
# useradd jenkinsvisudojenkins ALL=(ALL) NOPASSWD: ALL# mkdir jenkins_build
- Then copy the key generated on Day60 from master to agent node
$ ssh-copy-id jenkins@172.31.29.138# To test the connectivity$ ssh jenkins@172.31.29.138Last login: Fri Apr 12 04:31:49 2019
Step3: Add the agent from Jenkins UI
- On the Jenkins UI, Click on Manage Jenkins and then Manage Nodes
- Click on the New Node
* Name: Give your agent some name
* # of executors: The maximum number of concurrent builds that Jenkins may perform on this node.
* Remote root directory:An agent needs to have a directory dedicated to Jenkins. Specify the path to this directory on the agent. It is best to use an absolute path, such as /var/jenkins or c:\jenkins. This should be a path local to the agent machine. There is no need for this path to be visible from the master(/var/lib/jenkins/jenkins_build) created in earlier step
* Usage: Controls how Jenkins schedules builds on this node. Use this node as much as possible - This is the default setting.
In this mode, Jenkins uses this node freely. Whenever there is a build that can be done by using this node, Jenkins will use it.
* Credentials: Select the credentials to be used for logging in to the remote host.
* Host: Enter the hostname or IP address of your agent node in the Host field.
- Check if everything works
- To use the slave node
*
* Restrict where this project can be run: Select the label we created in earlier step(jenkins_slave) this will make sure build run on agent host
- Run the job and you will see output like this
Looking forward from you guys to join this journey and spend a minimum an hour every day for the next 100 days on DevOps work and post your progress using any of the below medium.
- Twitter: @100daysofdevops OR @lakhera2015
- Facebook: https://www.facebook.com/groups/795382630808645/
- Medium: https://medium.com/@devopslearning
- Slack: https://devops-myworld.slack.com/messages/CF41EFG49/
- GitHub Link:https://github.com/100daysofdevops
Reference