Jenkins 2.0 setup on AWS.

ship-952292_960_720Easiest way to learn cloud technologies is to create a free account on Amazon Web Services. In here we will create a basic instance of ubuntu and setup that instance as Jenkins2.0 master and create another instance to make it a slave to master. I prefer step by step approach, so we will use AWS console instead of terminal which i will share later How To Install Jenkins using Ansible …

  1. Login to AWS console (assuming you have an AWS account they offer some free as well please do check on their site.
  2. Go to “Services” and click on “EC2”.
  3. Click on label  “Security Groups” It renders on right side default security group.
  4. Click on button on top “Create Security Group”.
  5. Fill the fields like below screen shot
  6. Screen Shot 2017-08-18 at 21.28.55
  7.  Click on button “Create”.
  8.  Click on “Instance” label and click on “Launch Instance”.
  9.  Select Image type as “ubuntu 16.4 LTS”.
  10.  Select instance type “t2.micro”.
  11.  Click on “Review and Launch”.
  12.  Click on “Edit Security Groups.”
  13.  Select security group created in Step-6.
  14.  Click on “Launch”.
  15.  It will pop up window saying “Select an existing keypair or create a new keypair.”
  16.  If you have already created a key pair select one or create one and download it on your local machine and keep it safe.
  17.  Click on “Launch Instance”.
  18.  You can see your instance “initializing” and running after in few mins.
  19.  you can name your instance as “master001”.
  20.  Run Command  ssh -i keypair.pem ubuntu@instance_dns_default_by_aws
  21.  Install java
    1. $  sudo apt-get update

    2. $  sudo apt-get install default-jre

    3. $  sudo apt-get install default-jdk

  22.  Install jenkins
    $ wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
    $ sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
    $ sudo apt-get update
    $ sudo apt-get upgrade
    $ sudo apt-get install jenkins
  23. Run Jenkins:
    $ sudo service jenkins start
  24. Create a slave instance as master on AWS.
  25. Setup basic JRE setup on AWS.
    $ sudo apt-get update
    $ sudo apt-get upgrade
    $ sudo apt-get install default-jre
  26. Create ssh key on master node by running
    ssh-keygen -t rsa
  27. Copy the key from id_rsa.pub  to slave instances .ssh/authorized_keys
  28. Run command on your master node (default algorthim may not let you connect from jenkins)                                                                                                                     ssh -o HostKeyAlgorithms=ssh-rsa ubuntu@master_instance_node

  29.  Navigate to url “master_instance_dns:8080/”
  30. It will ask the password and also show you the location of password which has to be retrieved by ssh to your master node.
  31. In Jenkins console go to Jenkins>>Manage Jenkins > manage nodes.
  32. Add node it opens up pop up window.
  33. in pop up window
    1. add name to your slave slave001.
    2. add remote root directory “/home/ubuntu/”.
    3. select from drop down “Launch Method” “Launch slave agents via ssh”.
    4. add Host “slave/node machine” and add credentials by copying private ssh key generated in master machine for user ubuntu.Screen Shot 2017-08-18 at 22.33.21.png
    5. Click on “Save”.
  34. Now you have jenkins master/slave running.

Cheers!! Create a pipeline and run it on this setup.

 

Published by sbcons

Sbcons has expertise in different areas of SDLC, provide solution, services and consultancy to all type of industry.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: