Code Monkey home page Code Monkey logo

task_4's Introduction

DEVOPS_TASK_4

Here is i use Jenkins bcz Jenkins supports the master-agent architecture (many build agents completing work scheduled by a master server) making it highly scalable. The master’s job is to schedule build jobs, distribute the jobs to agents for actual execution, monitor the agents, and get the build results. Master servers can also execute build job directly.

The agents’ task is to build the job sent by the master. A job can be configured to run on a particular type of agent, or if there are no special requirements, Jenkins can simply choose the next available agent.

This project will help to deploy a website using a Dynamic Distributed Jenkins Cluster on Kubernetes using a remote Slave Node. Everything is configured in such a way that at the moment developer will commit the Dockerfile and webUI code on GitHub, the slave will launch the Distributed cluster and the image will be built and pushed to Dockerhub and the Deployment will be started on K8s. If the developer updates the code and recommits it, the Cluster will use its Rolling Updates feature to update the Website and the website will be uploaded with zero Down Time.

TASK DESCRIPTION

Create container image that’s has Linux and other basic configuration required to run Slave for Jenkins. ( example here we require kubectl to be configured )

The slave image should have the ssh enabled with credentials and the root directory , java installed

Here i create Dockerfile for building an image which would work as Jenkins Agent having kubectl setup.

here i create a config file for k8s this help me When i launch the job it should automatically starts job on slave based on the label provided for dynamic approach.

I configure docker service file for launching the Dynamic slave using Docker containers remotely ,we have to do the following changes in the /usr/lib/systemd/system/docker.service so that the docker client can remotely connect to docker server.

here i add

-H tcp://0.0.0.0:<port_number>

when we sucessfully changing in the service file, then to update internal settings we need to run the following commands

       systemctl daemon-reload

       systemctl restart docker 

Now I Configure Cloud Node in Jenkins

First of all for this setup we need to have Docker plugin installed.

Go to Manage Jenkins > Manage Nodes and Clouds > Configure Clouds > Add a new Cloud > Docker

Here we need to specify the Docker Image Name , Name of the Node and the remote root directory and also the Label to be provided so that we can use it to restrict the job on this dynamic slave node.

Here we need to specify our username and password for ssh remote login and remote program execution.

Job1: Here I Pull the Github repo automatically when some developers push repo to Github and perform the following operations as:

Create the new image dynamically for the application and copy the application code into that corresponding docker image

Push that image to the docker hub (Public repository)

( Github code contain the application code and Dockerfile to create a new image )

Here i am creating the TASK_4 folder where Dockerfile and the code file will be copied from the Jenkins workspace an after copy it will be pushed to dockerhub

After successfully job1 run then job2 trigger

Job2 ( Should be run on the dynamic slave of Jenkins configured with Kubernetes kubectl command): Launch the application on the top of Kubernetes cluster performing following operations:

If launching first time then create a deployment of the pod using the image created in the previous job. Else if deployment already exists then do rollout of the existing pod making zero downtime for the user.

If Application created first time, then Expose the application. Else don’t expose it.

Here I have chained this job with job1 and had provided the label to restrict on which node this job should be performed.

The Dockerfile i have metioned at top i used that to build the image for cloud slave node and then whenever this job will be triggered it will

First check for the deployment if no deployment is there it will create one and will expose the deployment .

It create deployment of k8s

launch oursite

task_4's People

Contributors

vishnupal 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.