Location>code7788 >text

Jenkins Deployment Architecture Overview

Popularity:54 ℃/2024-08-13 10:44:14

1, Jenkins is what

Jenkins is an open source , provide a user-friendly interface for continuous integration (CI) tool , originated in Hudson , mainly used for continuous , automated build/test software projects , monitor the operation of external tasks .

Jenkins written in Java, can be run in Tomcat and other popular servlet containers , can also run independently . Usually used in conjunction with version management tools (SCM), build tools . Jenkins can be very good support for a variety of languages to build the project , but also fully compatible with Maven, Ant, Gradle and other third-party build tools , at the same time, with the SVN, GIT and other commonly used version control tools seamlessly integrated , but also supports the direct interface to the GitHub and other source code hosting sites .

2, Jenkins deployment architecture overview
  • One is to directly use a single Master installation of Jenkins, direct task management and business build release, but there may be some production security risks.
  • One is the Master plus Agent model. the Master node mainly handles scheduling build jobs, distributes builds to Agents for actual execution, and monitors the status of Agents. The work of business build distribution is given to the Agent to carry out, i.e., to execute the tasks assigned by the Master and return the progress and results of the tasks.

Jenkins Master and Agent can be installed in virtual machines or containers, and can be combined in various forms.

3, Jenkins deployment architecture details

3.1 Single-node architecture (single Master)

Single Master installation of Jenkins, direct task management and business build release. Single Master installation of Jenkins for virtual machines can be found in theCentos7 under the installation and configuration of the latest version of Jenkins (2.452.3)" This blog post.

For some specific scenarios, a single node is not sufficient: the

  • If all executing programs are busy with build tasks, the job (Job) must wait.
  • When the number or load of projects increases, it is likely to run out of resources.

In order to get the Jenkins infrastructure back up and running, servers need to be augmented by adding RAM, CPU, etc., which is not scalable, and servers must be maintained and upgraded as needed.

During maintenance upgrades, the build environment will be shut down, jobs will have to be stopped, and the entire Jenkins infrastructure will be unavailable.

This single-node architecture causes the system to be in a constant state of idel, and the resources allocated to the Jenkins environment are not fully utilized in this state.

The single-node architecture also introduces security issues because Jenkins users have full access to all resources and workspaces.

For all these reasons, Jenkins supports a distributed architecture where the workload of building a project is delegated to multiple Jenkins agents.

3.2 Distributed Architecture (Master plus Agent)

The Master node mainly deals with scheduling build jobs, distributing builds to Agents for actual execution, and monitoring the status of Agents. The work of business build distribution is left to the Agent, i.e., it executes the tasks assigned by the Master and returns the progress and results of the tasks.

Jenkins Master and Agent can be installed in virtual machines or containers, you can choose one of the options to implement according to their needs:

  • Fixed Agent (generally a virtual machine): Agent has been running, the task will not be destroyed after the completion of the construction, after the creation of the completion of the cluster will always occupy the resources, the configuration process is simpler.
  • Dynamic Agent (generally k8s): dynamically create Agent containers when building tasks, and destroy the containers after the completion of the task build, which can achieve dynamic allocation of resources, high resource utilization, but the configuration process is more complex.

The following dynamic Agent (k8s cluster) Jenkins distributed structure as an example to show the Jenkins distributed architecture.

The master node is responsible for.

  1. Scheduling build jobs.
  2. Distribute the build job to the agent for actual execution.
  3. Monitor the Slave node (Slave) and stop it as needed.
  4. You can also execute jobs directly if all Jenkins agents are occupied.

The Jenkins agent is responsible for.

  1. Receiving requests or work from the master node, the agent's job is to act on command.
  2. Jobs can be configured to always execute on a specific agent.
  3. The master node will utilize its resources to process HTTP requests and manage the build environment, and the actual execution of the build will be delegated to the proxy.

With this configuration, it is possible to horizontally scale the Jenkins architecture, where Jenkins will be installed on a single node.

Main reference:/bestpractice-cce/cce_bestpractice_0066.html