Tuesday, September 24, 2019

Jenkins Setup - Install Java , Master Jenkins on Ubuntu EC2 Instance

Please follow steps to install Java, Jenkins on Ubuntu EC2. Jenkins is a java-based application, so you need to install Java first. 

Java Setup on Ubuntu


To install this version, first update the package index:

$ sudo apt-get update

Verify the Java version

Installing Specific Versions of OpenJDK

Java 11 is the current Long Term Support version and is still widely supported, though public maintenance ends at least September 2022 for AdoptOpenJDK. To install OpenJDK 8, execute the following command:

$ sudo apt-get install openjdk-11-jdk -y not to ask for the runtime



type "Y"  to continue installing java  



Verify that this is installed with and You’ll see output like this:
$ java -version




Steps to install the Jenkins:

Introduction :


Jenkins is an open-source automation server that automates the repetitive technical tasks involved in the continuous integration and delivery of software. Jenkins is Java-based and can be installed from Ubuntu packages or by downloading and running its web application archive (WAR) file — a collection of files that make up a complete web application to run on a server.

Step 1:  Intalling Jenkins

First, add the repository key to the system:


$ wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -

When the key is added, the system will return OK. like in the below image
Next, append the Debian package repository address to the server’s sources.list:

$ sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'

When both of these are in place, run update so that apt will use the new repository:

ubuntu@ip-172-31-41-76:~$ sudo apt-get update

Finally, install Jenkins and its dependencies:

Now that Jenkins and its dependencies are in place, we’ll start the Jenkins server.


Step 2: Starting Jenkins
Let’s start Jenkins using systemctl:
  ubuntu@ip-172-31-41-76:~$ sudo systemctl start jenkins

Since systemctl doesn’t display output, you can use its status command to verify that Jenkins started successfully:
If everything went well, the beginning of the output should show that the service is active and configured to start at boot:

Now that Jenkins is running, let’s adjust our firewall rules so that we can reach it from a web browser to complete the initial setup.

Step 2: Opening the Firewall

By default, Jenkins runs on port 8080, so let’s open that port using ufw:

Check ufw’s status to confirm the new rules:


Note: If the firewall is inactive, the following commands will allow OpenSSH and enable the firewall:







Check ufw’s status again to confirm 



With Jenkins installed and our firewall configured, we can complete the initial setup.

Step 4: Setting Up Jenkins

To set up your installation, visit Jenkins on its default port, 8080, using your server domain name or IP address: http://your_server_ip_or_domain:8080
Eg : http://3.15.210.35:8080



You should see the Unlock Jenkins screen, which displays the location of the initial password:

========================================================================
                 This will help us in case of unable to connect with jenkins server
========================================================================
Note:  if you are unable to connect Jenkins server with your public ip address or hostname like the above image, then follow the below steps 


It seems you have not opened your 8080 port in Security Groups in AWS.
Steps:
  1. Go to AWS console
  2. Click Security Group and select the security group that you have assigned to your EC2 instance.
  3. Click Edit Inbound Rules
  4. Add a Custom TCP Rule and add 8080 in the Port Range.

 5. You will now see Jenkins rise from the grave :) i.e. first-time installation screen.
==========================================================================
In the terminal window, use the cat command to display the password:
 $ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy the 32-character alphanumeric password from the terminal and paste it into the Administrator password field, then click Continue.

The next screen presents the option of installing suggested plugins or selecting specific plugins:

We’ll click the Install suggested plugins option, which will immediately begin the installation process:


When the installation is complete, you will be prompted to set up the first administrative user. It’s possible to skip this step and continue as using admin the initial password we used above, but we’ll take a moment to create the user and click on Save and Continue.


Enter the name and password for your user:





You will see an Instance Configuration page that will ask you to confirm the preferred URL for your Jenkins instance. Confirm either the domain name for your server or your server’s IP address:





After confirming the appropriate information, click Save and Finish. You will see a confirmation page confirming that “Jenkins is Ready!”:

Click Start using Jenkins to visit the main Jenkins dashboard:


At this point, you have completed a successful installation of Master Jenkins.



Monday, September 23, 2019

How to Connect AWS-EC2 ubuntu instance using Putty

Step 1: Click and open  "Putty gen"  
Step 2: Click on "Load" button and check for "key-Name.pem

Step 3: Key loaded successfully and will see the window like below image
Step 4: Click on "Save private key" with "key-name.ppk" 
Step 5: Open "Putty" tool from desktop
Step 6: Enter "public ip address" of AWS-EC2 ubuntu instance


Step 7: Please follow the below image to upload the "aws-ecs.ppk" key


 Step 8:  Accept the "Security Alert" as "Yes" then enter the "AWS-EC2" instance username as ubuntu and press enter.

Saturday, September 21, 2019

How to setup AWS EC2 instance



Please follow the below steps to create an EC2 instance. The EC2 instance is a virtual server provided by AWS. We will be using this EC2 to install Java, Jenkins, Docker, etc. We will be using this as a CI server.

Steps:

             
1: Enter the "https://aws.amazon.com/" in the address bar and click on the "Sign in to the Console"
         


2. Enter  AWS Console Username and Password and click on Sign in


3: Go to the AWS console. click on Services --> Click on EC2

4: Click on Launch instance. Choose an Amazon machine image (AMI), click next
5: Select Ubuntu Server 18.04 LTS (HVM), SSD Volume Type - ami-05c1fa8df71875112 (64-bit x86) / ami-0606a0d9f566249d3 (64-bit Arm)
6: Choose an Instance Type and click on Next: Configure Instance Details
 7: Leave values to default and click on Next in Step 3 and Step 4 

8: Click on Next : Add Tags to enter the Tag Name and click on Add Tag and enter the KEY and VALUE pair  and click on Next: Configure Security Group 
Note : A tag consists of a case-sensitive key-value pair. For example, you could define a tag with key = ubuntu and value = ubuntu-jenkins-master.
9:  Click create new security group, give name as MyJenkinsSecurityGroup, add a custom rule for 8080, 8090, allow 0.0.0.0/0 as source IP

10: Click on Review and Launch and then you will see the "Review Instance Launch" like all the previous steps the below image

11. Selecting an existing key pair or create a new key pair. 
choose to create a new key pair and  Please do not give any space or any character in naming the key.
Once you click on "Download key pair", the key will be downloaded/stored to your "Downloads" folder with provided name like "aws-ubuntu.pem".

12: Click on Launch Instances and click on Instance id to see the complete instance status
13: Once instance is created. you can see it running..



How to install and setup Kubernetes cluster using kOps in AWS environment

  Kops: Kops is also known as Kubernetes Operations, it is an open-source project which helps you to create, upgrade, destroy, and maintain ...