{"id":2718,"date":"2018-09-24T10:51:31","date_gmt":"2018-09-24T09:51:31","guid":{"rendered":"http:\/\/www.xenonique.co.uk\/blog\/?p=2718"},"modified":"2018-09-24T10:51:31","modified_gmt":"2018-09-24T09:51:31","slug":"hot-shot-011-jenkins-on-aws-part-1","status":"publish","type":"post","link":"https:\/\/www.xenonique.co.uk\/blog\/2018\/09\/24\/hot-shot-011-jenkins-on-aws-part-1\/","title":{"rendered":"Hot shot 011 &#8211; Jenkins on AWS (part 1)"},"content":{"rendered":"<p>This are my verbatim notes to the PEAT UK podcast:<\/p>\n<p> &nbsp; <\/p>\n<p> &nbsp; <\/p>\n<p>Hello there once again to another hot shot. My name is Peter Pilgrim.<\/p>\n<p>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.<\/p>\n<p>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. <\/p>\n<p>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.<\/p>\n<p>In a subsequent show, I will cover Jenkins AWS EC2 instance with master and slave show. <\/p>\n<p> &nbsp; <\/p>\n<p> &nbsp; <\/p>\n<p><iframe loading=\"lazy\" width=\"100%\" height=\"300\" scrolling=\"no\" frameborder=\"no\" allow=\"autoplay\" src=\"https:\/\/w.soundcloud.com\/player\/?url=https%3A\/\/api.soundcloud.com\/tracks\/503750334&#038;color=%23ff5500&#038;auto_play=false&#038;hide_related=false&#038;show_comments=true&#038;show_user=true&#038;show_reposts=false&#038;show_teaser=true&#038;visual=true\"><\/iframe><\/p>\n<p> &nbsp; <\/p>\n<p> &nbsp; <\/p>\n<p>Let\u2019s move on, the way I started with Jenkins is that I chose a Amazon Machine Image, AMI and namely with a typical burstable instance (<code>t2.micro<\/code>)<\/p>\n<p>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\u2019t 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 \u201cJenkins master\u201d. 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<\/p>\n<p>So I created a Jenkins server master in your EC2 instance, check and verify the settings. Launch the EC2 instance. You don\u2019t need to create any user data at all.<\/p>\n<p>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.<\/p>\n<p> &nbsp; <\/p>\n<p> &nbsp; <\/p>\n<p>First, you must execute a YUM updates.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo yum update -y\r\n<\/pre>\n<p>We, then, add a Jenkins repository and start the System V job.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ sudo wget -O \/etc\/yum.repos.d\/jenkins.repo  https:\/\/pkg.jenkins-ci.org\/redhat\/jenkins.repo\r\n$ sudo rpm --import https:\/\/pkg.jenkins.io\/redhat\/jenkins.io.key\r\n$ sudo yum install jenkins -y\r\n<\/pre>\n<p>At this moment, you should be to browse Jenkins running on the EC2 instance. Point your favourite browser to <code>https:\/\/publicly-assigned-IP-address:8080\/<\/code><\/p>\n<p>You will be greeted a screen requiring a master password. You will find it under the following <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ ls -l \/var\/lib\/jenkins\/secrets\/initialAdminPassword\r\n$ sudo cat \/var\/lib\/jenkins\/secrets\/initialAdminPassword\r\n<\/pre>\n<p>Stop the Jenkins Server now with the command <code>sudo service jenkins sta<\/code>rt <\/p>\n<p>In this Amazon AMI linux, I remove the older Java 7 packages and then installed OpenJDK 8  and the runtime environment.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ which java \r\n$ java -version\r\n$ sudo yum remove java-1.7.0-openjdk\r\n<\/pre>\n<p>Now install JDK 8 with the following:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ sudo yum install java-1.8.0-openjdk   java-1.8.0-openjdk-devel  \r\n$ which java\r\n$ java -version\r\n$ ls -l \/usr\/bin\/java\r\n$ ls -l \/etc\/alternatives\/java\r\n$ ls -l \/usr\/lib\/jvm  \r\n\r\nI also install extra Linux utilities in order to send email to other servers.\r\n\r\n\r\nsudo yum install git  mailx  mailutils\r\n<\/pre>\n<p>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<\/p>\n<p>I physically use WGet to download Apache Maven, Gradle and Groovy<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ mkdir ~\/Products\r\n$ cd ~\/Products\r\n$ wget https:\/\/www.mirrorservice.org\/sites\/ftp.apache.org\/maven\/maven-3\/3.5.4\/binaries\/apache-maven-3.5.4-bin.zip\r\n$ sudo unzip apache-maven-3.5.4-bin.zip -d \/usr\/local\/\r\n\r\n$ wget https:\/\/dl.bintray.com\/groovy\/maven\/apache-groovy-binary-2.5.2.zip\r\n$ sudo unzip apache-groovy-binary-2.5.2.zip -d \/usr\/local\r\n\r\n$ wget https:\/\/services.gradle.org\/distributions\/gradle-4.9-bin.zip\r\n$ sudo unzip gradle-4.9-bin.zip -d \/usr\/local\r\n<\/pre>\n<p>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:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n### .${HOME}\/bash_profile\r\n# Get the aliases and functions\r\nif [ -f ~\/.bashrc ]; then\r\n        . ~\/.bashrc\r\nfi\r\n\r\n# User specific environment and startup programs\r\n\r\nexport GRADLE_HOME=\/usr\/local\/gradle-4.9\r\nexport GROOVY_HOME=\/usr\/local\/groovy-2.5.2\r\nexport M2_HOME=\/usr\/local\/apache-maven-3.5.4\r\nexport JAVA_HOME=\/usr\/lib\/jvm\/java-1.8.0-openjdk.x86_64\r\n\r\nexport ORIGINAL_PATH=\/usr\/local\/bin:\/bin:\/usr\/bin:\/usr\/local\/sbin:\/usr\/sbin:\/sbin:\/opt\/aws\/bin:${HOME}\/.local\/bin:${HOME}\/bin\r\n\r\nPATH=.:${HOME}\/.local\/bin:${HOME}\/bin:\\\r\n${GRADLE_HOME}\/bin:${GROOVY_HOME}\/bin:${M2_HOME}\/bin:\\\r\n${JAVA_HOME}\/bin:${JAVA_HOME}\/jre\/bin:\\\r\n\/usr\/local\/bin:\/bin:\/usr\/bin:\/usr\/local\/sbin:\/usr\/sbin:\/sbin:\/opt\/aws\/bin\r\nexport PATH\r\n<\/pre>\n<p>Note from the above that I saved the original AMI default system PATH just in case of SNAFU.<\/p>\n<p>I then stopped and restarted the Jenkins access with the administration password.<\/p>\n<p>Go back to the AWS console, EC2 dashboard. Create a custom AMI for your private purposes and name something  Jenkins master Linux AMI.<\/p>\n<p>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.<\/p>\n<h1> HIRE ME &#8211; AVAILABLE OCTOBER 2018<\/h1>\n<p>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.<\/p>\n<p>That&#8217;s all for me. Bye for now<\/p>\n<p> &nbsp; <\/p>\n<p> &nbsp; <\/p>\n<p>*** INSERT SIDE NOTE ABOUT ANSIBLE AND TERRAFORM ***<\/p>\n<p>+PP+<br \/>\nSeptember 2018<\/p>\n<p> &nbsp; <\/p>\n<p> &nbsp; <\/p>\n<p>By the way, all your Shares, Likes, Comments are always more than welcomed!<\/p>\n<p> &nbsp; <\/p>\n<p> &nbsp; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>This are my verbatim notes to the PEAT UK podcast: &nbsp; &nbsp; 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[206,111,194,201,133,198,195,175],"tags":[],"_links":{"self":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/2718"}],"collection":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=2718"}],"version-history":[{"count":2,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/2718\/revisions"}],"predecessor-version":[{"id":2720,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/2718\/revisions\/2720"}],"wp:attachment":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=2718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=2718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=2718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}