Jenkins Master (Server)
Jenkins’s server or master node holds all key configurations. The Jenkins master server is like a control server that orchestrates all the workflow defined in the pipelines. For example, scheduling a job, monitoring the jobs, etc.
Jenkins Agent
An agent is typically a machine or container that connects to a Jenkins master and this agent executes all the steps mentioned in a Job. When you create a Jenkins job, you have to assign an agent to it. Every agent has a label as a unique identifier.
When you trigger a Jenkins job from the master, the actual execution happens on the agent node that is configured in the job.
A single, monolithic Jenkins installation can work great for a small team with a relatively small number of projects. As your needs grow, however, it often becomes necessary to scale up. Jenkins provides a way to do this called “master to agent connection.” Instead of serving the Jenkins UI and running build jobs all on a single system, you can provide Jenkins with agents to handle the execution of jobs while the master serves the Jenkins UI and acts as a control node.
How to connect the master and node machine via ssh:-
Create the master SSH instance. Go to the terminal.
Use the ssh-keygen command as follows.
Check ssh-keygen id is created or not.
Check the public key of that id.
Now we have created an agent-node ssh instance.
Check ssh id.
Paste the public key in the authorized key.
Now we are creating nodes in Jenkins.
Dashboard->ManageJenkins->Manage Nodes and clouds->New Node->
Click on Create. And fill in the information.
At Host provides the public IP of the agent node. Then provide the private key and click on add.
Now go to the agent-node terminal and apply the following commands:-
sudo apt-get update
sudo apt-get install openjdk-11-jre
Here your agent is launched.
Now create a new pipeline.
Click on Save. Click on Build Now.
Now you can check on the agent-node terminal is the pipeline running successfully or not.
Again go to the agent-node terminal. And install docker via the following commands.
sudo apt-get install docker.io docker-compose
sudo usermod -aG docker $USER