Tuesday, June 29, 2021

How to Integrate Jenkins and GitHub using SSH keys? | Jenkins and GitHub Integration

GitHub removed password authentication support from August 13, 2021 instead it recommends to use either OAuth or Personal Access Token. We will see how to connect to GitHub from Jenkins using SSH keys instead of using user name and password.

It is also a good practice to use SSH keys in Jenkins jobs instead of using user name and password.


Watch the steps in YouTube channel:

Pre-requistes:

  • Jenkins is up and running
  • Credentials plug-in installed in Jenkins

Create SSH keys in your Jenkins EC2 instance

ssh-keygen

enter four times. this will create keys in .ssh folder.

Copy and paste the public key
sudo cat ~/.ssh/id_rsa.pub

Add public Keys into your respective GitHub

Add public keys into your Repository--> settings--> Deploy keys section




Click on Add Deploy Key and enter public keys and save.

Add Private Keys in Jenkins Master
Login Jenkins. Go to Manage Jenkins. click on Credentials



Click on Jenkins


Click on Global Credentials



Click on Add Credentials


Choose SSH username with private key






Choose SSH username with private key
username can be anything
Click on enter directly under private key option and Click Add


Copy and paste private key(not public key) of your from Jenkins instance. command is below:
sudo cat ~/.ssh/id_rsa

copy the content of whole output from above command.
Click OK to save.

Now go to any Jenkins Job, you can choose this option for checking out from GitHub. Make sure you enter SSH url not https url.




That's it. This is how you use SSH url and private keys to checkout code from bitbucket or Github without entering username/password in Jenkins.


Click here to authenticate with GitHub using Personal Access Token.

Wednesday, June 9, 2021

AWS, Azure Cloud and DevOps Coaching Online Classes | Oct 2021 Schedule

Are you in IT? Tired of your work? Are you not able to make any good progress in your career? 
Are you not having a job? Looking for a break in IT? Are you interesting in learning about DevOps? 
 
Did you get laid off from your previous job due to Covid-19
 
You are in the right place to kick start your career in DevOps. DevOps is one of the top and hot IT skills right now. Currently almost all the employers are struggling to get right resources in their teams who can do the DevOps and automation work..You could be that person by attending this coaching program.

DevOps Coaching Classes schedules (Only online classes offered due to Covid-19)

Date Time Type When?
Oct 21st 6:00 to 7:45 PM CST Weekdays Tues/Thursday
Oct 23rd 11:35 AM to 01:15 PM CST on Saturdays
         &
02:00 PM to 4 pm CST on Sundays
Weekends Sat/Sun

DevOps Coaching Highlights:

- Comprehensive hands on knowledge on Git, Jenkins, Maven, SonarQube, Nexus, Terraform, Ansible, Puppet, Docker, AWS IAM, ECR, Docker registry. AWS and Azure cloud platforms.

- Coach is having about 21+ yrs of professional IT experience, 5+ Yrs in DevOps/Cloud/Automation.

- Many students already got placed in reputed companies from this coaching program successfully.

- Working as a Sr.DevOps Coach/Architect in a one of the top IT services companies in USA.

- Unique program...less theory, more hands on lab exercises...
 
Resume preparation will be done with candidates personally.

One-to-one Interview coaching.

- Coaching is purely hands on with 101% job relevant.

100% Job assistance.

- Coached about  950+ people successfully for past 4 years and many of my students got placed with many large enterprises in DFW, Charlotte, Houston, Austin, Chicago, Florida, Seattle, Bay area, Ohio, NJ and NY areas..

Contact no: 469-733-5248
Email - devops.coaching@gmail.com
Contact: AK

Monday, June 7, 2021

How do you import existing resources into Terraform from AWS? | Terraform Import command

Let's say that you have created EC2 instances manually. If you like to attach your EC2 instance to Terraform you can use import command.

 The terraform import command is used to import existing infrastructure. The command currently can only import one resource at a time. This means you can't yet point Terraform import to an entire collection of resources such as an AWS VPC and import all of it. 

Watch the steps in YouTube Video:


To import a resource, create a tf file first write a resource block for it in your configuration, establishing the name by which it will be known to Terraform:


sudo vi myec2.tf

resource "aws_instance" "myinstance" {

  # ...instance configuration...leave this as it is

}


terraform import can be run to attach an existing EC2 instance to this resource configuration:


pick up the instance ID of EC2 instance you want to import and execute the below command:
terraform import aws_instance.myinstance i-abcd1234


Saturday, June 5, 2021

Install AWS CLI on Windows | How to install AWS CLI on Windows

The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

Pre-requisites:

Before you can install or update the AWS CLI version 2 on Windows, be sure you have the following:

  • A 64-bit version of Windows XP or later.
  • Admin rights to install software
AWS CLI Installation Steps on Windows
Open command prompt on your windows machine, not Git bash.

msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi

Start installing AWS CLI by clicking next.

aws --version



Install AWS CLI on MAC OS | How to install AWS CLI on MAC OS


The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.


curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"

sudo installer -pkg AWSCLIV2.pkg -target / 

aws --version

aws-cli/2.2.9 Python/3.9.5 Darwin/20.4.0 source/arm64 prompt/off

Thursday, June 3, 2021

Jenkins Build Agent Setup | How to Setup Jenkins Slave on Ubuntu | Setup build agent and Integrate with Jenkins Master

Jenkins has powerful feature of master slave architecture which enables distributed builds. This article we will learn how to establish slave nodes on Ubuntu machines and integrate with Jenkins Master.

 
Please watch the lab in YouTube


Let us learn more about Jenkins master and slave:

Jenkins Master
Your main Jenkins server is the Master. The Master’s job is to handle:
  • Scheduling build jobs.
  • Dispatching builds to the slaves for the actual execution.
  • Monitor the slaves (possibly taking them online and offline as required).
  • Recording and presenting the build results.
  • A Master instance of Jenkins can also execute build jobs directly.
Jenkins Slave
A Slave is a Java executable that runs on a remote machine. Following are the characteristics of Jenkins Slaves:
  • It hears requests from the Jenkins Master instance.
  • Slaves can run on a variety of operating systems.
  • The job of a Slave is to do as they are told to, which involves executing build jobs dispatched by the Master.
  • You can configure a project to always run on a particular Slave machine, or a particular type of Slave machine, or simply let Jenkins pick the next available Slave.
Let us see how to configure slave nodes on Ubuntu EC2. If you like to learn how to setup Jenkins Master on Ubuntu EC2 instance, click here.

Jenkins Master uses SSH keys to communicate with slave. You need to create ssh keys in Jenkins master by executing below command.

Pre-requistes:

Steps involved:
1. Setup EC2 instance for slave
2. Create jenkins user and Install Java, Maven in Slave node
3. upload public keys from master to slave node.
4. verify ssh connection from master to slave
5. Register slave node in Jenkins master
6. Run build jobs in Jenkins slave

Slave node configuration

(You need to use new micro or small Ubuntu instance for this slave)
only port 22 needs to be open

Install Java

sudo apt-get update
sudo apt-get install default-jdk -y

Install Maven
sudo apt-get install maven -y

Create User as Jenkins
sudo useradd -m jenkins
sudo -u jenkins mkdir /home/jenkins/.ssh




Add SSH Keys from Master to Slave 

Execute the below command in Jenkins master EC2.
sudo cat ~/.ssh/id_rsa.pub

Copy the output of the above command:

Now Login to Slave node and execute the below command
sudo -u jenkins vi /home/jenkins/.ssh/authorized_keys

This will be empty file, now copy the public keys from master into above file.
Once you pasted the public keys in the above file in Slave, come out of the file by entering wq!

Now go into master node

ssh jenkins@slave_node_ip





this is to make sure master is able to connect slave node. once you are successfully logged into slave, type exit to come out of slave.





Now copy the SSH keys into /var/lib/jenkins/.ssh by executing below command in master(make sure you exited from slave by typing exit command:

sudo cp ~/.ssh/known_hosts  /var/lib/jenkins/.ssh

Because jenkins master will look keys from the above folder.

Register slave node in Jenkins:

Now to go Jenkins Master, manage jenkins, manage nodes.










Click on new node. give name and check permanent agent.
give name and no of executors as 1. enter /home/jenkins as remote directory.
select launch method as Launch slaves nodes via SSH.
enter Slave node ip address as Host.











click on credentials. Enter user name as jenkinsMake jenkins lowercase as it is shown.
 Kind as SSH username with private key. enter private key of master node directly by executing below command:

sudo cat ~/.ssh/id_rsa
(Make sure you copy the whole key including the below without missing anything)
-----BEGIN RSA PRIVATE KEY-----
-----
-----END RSA PRIVATE KEY-----

click Save.
select Host key verification strategy as "manually trusted key verification strategy".

Click Save.
Click on launch agent..make sure it connects to agent node.



Now you can kick start building the jobs, you will see Jenkins master runs jobs in slave nodes.

How to Setup SonarQube on Azure VM | Install SonarQube Server on Ubuntu 18.0.4 VM in Azure Cloud

SonarQube is one of the popular static code analysis tools. SonarQube enables developers to write cleaner, safer code. SonarQube is open-sou...