This Project will help you learn how to implement continuous integration and continuous deployment on AWS Ec2 servers using various DevOps tools like Jenkins, Maven, Docker, Ansible and Git
Prerequisites
Linux and basic commands.
General knowledge of the cloud, containerization and the above tools would be good to start.
What is DevOps?
Development + Operations
🎉
DevOps is a set of practices that combines software development and IT operations. It aims to shorten the systems development life cycle and provide continuous delivery with high software quality.
Basics of Deployment
Before we start with our projects let's brush up on some basics. I will talk about the steps we undergo to deploy any app or website on webservers (apache tomcat)
- You have code ready for your application/website created by you or your developer.
- You will deploy this code (build file) on a Web server (apache tomcat) which will help you access your website through the internet using HTTP/HTTPS protocols
- For you to place your code in Webserver you need to install it on your Hosted server (EC2). So when your website is up and ready users can access it through domain or hosted servers IP address.
- You can automate all of the above-listed things with just a single click or even not a click. (Power of DevOps) Let's Get Started To start we need to have source code you can either use yours if you have one or download/clone my GITHUB basic project. You can clone/use my if you don't have one. Now we are going to launch two LINUX instances: One Instance to host Jenkins. Jenkins will help us create build files(.war) which we will deploy on Tomcat Server hosted on another EC2 Linux Instance. One to host Apache Tomcat Webserver. Tomcat will hold this build file and will help users/clients to access it on the internet using the HTTP protocol. Do not worry I will also help you install all these tools and software on your Linux EC2 servers. 😄 Let's Launch EC2 instances ☁
- Log into AWS console & select EC2 service.
- Click on Launch instance
You will see a window with Amazon machine images(AMI) full of different operating systems and readymade software or CMS like WordPress but SELECT the AMAZON LINUX AMI.
Choose t2.micro (free tier eligible)
Now go ahead with the default settings >> NO need for Storage >> Add Tags for clear identification: Name Jenkins >> In SECURITY GROUP window open port 8080 for Jenkins and port 22 for SSH and click "Review and Launch" >> LAUNCH >> If you are a new user in new user and don't have any KeyPairs (needed for SSH login) download a KeyPair (name the key "DevOps Key" for reference
👍
) >> Keep the .pem file safe we might need it.
Your Instance would be launched and you will see a window with an instance in a pending state.
Wait for a few minutes and it will get Running with status checks passed 2/2
ONCE you have an instance you can see all the details about your instance like IP addresses, Security Group attached to it, Instance size, type, and others.
Now we will CONNECT to our LINUX instance we can do it by using PuTTY (long process) but we will do it using a shorter one provided by the EC2 service follow these small steps and you will enter the Linux world of Terminal :Click on "CONNECT" >> you will see different options to connect select "EC2 Instance Connect" Click on the Orange Connect button
- A new tab will open with SHELL and
- Congratulations! You are inside the Jenkins EC2 server.
- Here we will Install Jenkins which builds the code and test it and give us build file (.war) which will host on Apache Tomcat. Installing JAVA & MAVEN on AMAZON linux instance.
Here you will learn about some Linux command to install, navigate ,edit and create files. (You should know about Linux Commands)
Installing Java🍵
To install Jenkins we need to install Java in your server so run this command.
sudo yum install java-1.8.0-openjdk.x86_64
// to change user to root
sudo su -
cd ~
//edit .bash_profile file
vi .bash_profile
when you run "vi .bashprofile" command a vim editor window will open and edit ".bashprofile" by providing the java path and add :$JAVA_HOME as shown in the screenshot.
to save this file press esc and type ":wq" this will save your file and close vim editor. Now if you type "which java" command
and you see this output then you have successfully downloaded and placed JAVA file!!
Install Maven
We need to run maven command in our project to get the build file necessary to host on the Apache webserver so as to download Maven.
Run this command to download
`wget https://dlcdn.apache.org/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.tar.gz`
This will download maven .tar file untar the file with command:
`tar xzvf apache-maven-3.8.3-bin.tar.gz`
Now you have successfully installed Maven and all the necessary files if you run "ls -a" you will see all the maven files
`cp -r apache-maven-3.8.3 /opt`
copy the apache-maven-3.8.3 file in /opt file and make changes in .bash_profile file as shown in the image. (this step is important you will know the reason later)
(You will see why we did this while creating Jenkins Job - pt. 2)
Top comments (0)