Git Product home page Git Product logo

dynamic-provisioning-of-slave-node-jenkins's Introduction

DYNAMIC PROVISIONING OF SLAVE-NODES IN JENKINS CLUSTER USING DOCKER

jenkins-docker

WHAT IS DYNAMIC PROVISIONING?

Dynamic provisioning means provision of slave nodes as and when needed i.e. when we need to run any job in jenkins to save the resources

Now let's try to implement this concept by integrating JENKINS with MAVEN using MASTER and SLAVE in Linux OS.

1- Configure a Docker Host With Remote API :

Jenkins master connects to the docker host using REST APIs. So we need to enable the remote API for our docker host.

jenkins-docker

step1:

Open the docker service file /lib/systemd/system/docker.service. Search for ExecStart and replace that line with the following.

ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock

step2:

Reload and restart docker service.

$ sudo systemctl daemon-reload
$ sudo service docker restart

step3:

Validate API by executing the following curl commands. Replace 54.221.134.7 with your host IP.

$ curl http://localhost:4243/version
$ curl http://54.221.134.7:4243/version
2- Configure Jenkins Server With Docker Plugin :
  • Head over to Jenkins Dashboard –> Manage Jenkins –> Manage Plugins. jenkins-docker

  • Head over cloud configuration under Manage Jenkins –> Manage Nodes and Clouds

jenkins-docker

  • Add docker Agent Template.

jenkins-docker

Note:

Replace “Docker URI” with your docker host IP. For example, tcp://10.128.0.3:4243 You can use the “Test connection” to test if Jenkins is able to connect to the Docker host.

3- Job in Jenkins Setup :

First we need plugins i.e. dependencies i.e. Git, Docker and Maven from Manage Jenkins --> Manage Plugins.

  • Create New Freestyle Project:

jenkins-docker

  • Now go to GENERAL and set options.

By-default job runs in master so we need to restrict it to run inside the slave-nodes.

jenkins-docker

  • Now go to SOURCE CODE MANAGEMENT and set options.

Here we take code from GitHub for testing purpose.

jenkins-docker

  • Now go to BUILD and set options.

We need to perform operations i.e. Test --> Compile --> Package.

jenkins-docker

  • Now go to POST BUILD ACTIONS and set options.

As we want to archive the package i.e. called ARTIFACT to download it in .jar extension to use it directly.

jenkins-docker

  • Now build the job in jenkins.

Now as soon as we build the job then docker will launch the container in which specified slave will set and then run the job inside it.

And after running the job automatically the container in docker and slave in cluster will be deleted

jenkins-docker

jenkins-docker

  • Console Output will show the output and whole process/steps involved in it.

jenkins-docker

-Workspace will show all the files and folders and we can also downloade The Artifact

jenkins-docker

dynamic-provisioning-of-slave-node-jenkins's People

Contributors

oussamamaroufi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.