PEAT Online Course -
How To Improve Your Personal Performance in Java work Technology

  • YOU + CONTROL
  • Focus
  • Autonomy
  • Proficiency
  • Purpose
  • Covid-19!!!
  • Deep Hidden Meaning
  • FREE updates
GET 75% OFF NOW
Your Promo code: TECHLAYOFF
Exclusively on
VIMEO ON-DEMAND

Hot shot 011 – Jenkins on AWS (part 1)

24 September 2018 Comments off

5 minutes

1063

This are my verbatim notes to the PEAT UK podcast:

 

 

Hello there once again to another hot shot. My name is Peter Pilgrim.

I have been a DevOps specialist, welcome to another episode. This is hotshot 11 Jenkins n AWS part one, I have been a platform engineer and I am a Java Champion.

In this episode, I am going talk about setting up your own Jenkins server on AWS. I will cover simple and straightforward case, deploying just one Jenkins server on AMI. In a subsequent episode, I will talk about Jenkins main and slave nodes.

In order to follow along, I going to assume that you are already familiar AWS EC2 and how to create instances, how to start them, how to stop them and definitely how to terminate them. If you are unsure about any of this, then you need step back and learn how AWS works beforehand.

In a subsequent show, I will cover Jenkins AWS EC2 instance with master and slave show.

 

 

 

 

Let’s move on, the way I started with Jenkins is that I chose a Amazon Machine Image, AMI and namely with a typical burstable instance (t2.micro)

Navigate to your AWS console for your AWS account, go to into Services drop down, navigate to the EC2 dashboard. I selected the Amazon Linux AMI 201803 and the t2.micro (and this is also free-tier eligible). This AMI has 1 VCPU, 1 GB of memory and low-to-moderate performance. I configure this AMI to your VPC, you don’t need anything particularly sexy as your VPC, you can use the default one if you are experimenting. You might need a subnet and CIDR/range if you are running in a corporate environment (talk to your technical lead / head of DevOps / cloud administration for the necessary permissions and information). You do need an auto-assignment public IP, accept the 8GB HDD and add a name tag like “Jenkins master”. It takes about 3 minutes to create this EC2 instance. On year, enjoy in your security group that inbound HTTP port 8080 and SSH port 20 are set

So I created a Jenkins server master in your EC2 instance, check and verify the settings. Launch the EC2 instance. You don’t need to create any user data at all.

Now you need to look at my blog article, since this radio. You now need to SSH into the running EC2 instance, which will run Jenkins, with the public IP. Log into the instance as the ec2user.

 

 

First, you must execute a YUM updates.

sudo yum update -y

We, then, add a Jenkins repository and start the System V job.

$ sudo wget -O /etc/yum.repos.d/jenkins.repo  https://pkg.jenkins-ci.org/redhat/jenkins.repo
$ sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key
$ sudo yum install jenkins -y

At this moment, you should be to browse Jenkins running on the EC2 instance. Point your favourite browser to https://publicly-assigned-IP-address:8080/

You will be greeted a screen requiring a master password. You will find it under the following

$ ls -l /var/lib/jenkins/secrets/initialAdminPassword
$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Stop the Jenkins Server now with the command sudo service jenkins start

In this Amazon AMI linux, I remove the older Java 7 packages and then installed OpenJDK 8 and the runtime environment.

$ which java 
$ java -version
$ sudo yum remove java-1.7.0-openjdk

Now install JDK 8 with the following:

$ sudo yum install java-1.8.0-openjdk   java-1.8.0-openjdk-devel  
$ which java
$ java -version
$ ls -l /usr/bin/java
$ ls -l /etc/alternatives/java
$ ls -l /usr/lib/jvm  

I also install extra Linux utilities in order to send email to other servers.


sudo yum install git  mailx  mailutils

Here is you might want to also GNU C++ and other native libraries for the Redhat Linux, however this is going to be lightweight Jenkins server. So YAGNI rule applies

I physically use WGet to download Apache Maven, Gradle and Groovy

$ mkdir ~/Products
$ cd ~/Products
$ wget https://www.mirrorservice.org/sites/ftp.apache.org/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.zip
$ sudo unzip apache-maven-3.5.4-bin.zip -d /usr/local/

$ wget https://dl.bintray.com/groovy/maven/apache-groovy-binary-2.5.2.zip
$ sudo unzip apache-groovy-binary-2.5.2.zip -d /usr/local

$ wget https://services.gradle.org/distributions/gradle-4.9-bin.zip
$ sudo unzip gradle-4.9-bin.zip -d /usr/local

I also set up my favourite Bash Profile for Linux, which is cut down version without all the bells and whistle. It looks a little bit like this:

### .${HOME}/bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

export GRADLE_HOME=/usr/local/gradle-4.9
export GROOVY_HOME=/usr/local/groovy-2.5.2
export M2_HOME=/usr/local/apache-maven-3.5.4
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk.x86_64

export ORIGINAL_PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:${HOME}/.local/bin:${HOME}/bin

PATH=.:${HOME}/.local/bin:${HOME}/bin:\
${GRADLE_HOME}/bin:${GROOVY_HOME}/bin:${M2_HOME}/bin:\
${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin:\
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin
export PATH

Note from the above that I saved the original AMI default system PATH just in case of SNAFU.

I then stopped and restarted the Jenkins access with the administration password.

Go back to the AWS console, EC2 dashboard. Create a custom AMI for your private purposes and name something Jenkins master Linux AMI.

Side note: Yes I already know, you set up Jenkins on AWS using an configuration tool like Ansible or Terraform, but it is better for learners to get to grip directly with the AWS Console and EC2 Dashboard before they use intermediate tools.

HIRE ME – AVAILABLE OCTOBER 2018

I am looking for new contract gig. I am available in October, so get in touch and please share and retweet #Java #JDK8 microservices application development M/SOA, SpringBoot, #JavaEE, Cloud #AWS, #SoftwareArchitecture, coaching/mentoring and much more.

That’s all for me. Bye for now

 

 

*** INSERT SIDE NOTE ABOUT ANSIBLE AND TERRAFORM ***

+PP+
September 2018

 

 

By the way, all your Shares, Likes, Comments are always more than welcomed!

 

 

Hey all! Thanks for visiting. I provide fringe benefits to interested readers: checkout consultancy, training or mentorship Please make enquiries by email or
call +44 (0)7397 067 658.

Due to the Off-Payroll Working plan for the UK government, I am enforcing stricter measures on contracts. All potential public sector GOV.UK contracts engagements must be approved by QDOS and/or SJD Accounting. Please enquire for further information.