Skip to content

Latest commit

 

History

History
106 lines (83 loc) · 4.15 KB

CI_CD_Server.md

File metadata and controls

106 lines (83 loc) · 4.15 KB

AWS Configuration for Jenkins

We will be setting up a Jenkins, in the end we shoud have:

  1. An AWS EC2 instance running Ubuntu 22.04 LTS
  2. Jenkins setup running on Docker

To setup the environment, you need to have an AWS EC2 instance configured as follows:

  1. Log in to your AWS account
  2. After you are logged in, select the Services button:
  3. Select Compute
  4. Select EC2 for a Virtual Private Server in the cloud
    Alt text Alt text
  5. Launch a new instance by selecting Launch Instances: Alt text
  6. Fill in the Name of your server, and select the Amazon Linux image Alt text
  7. Leave the Instance Type section as is
  8. In the Key Pair section, select Create key pair fill in the details, and you will be prompted to download the key .pem file, and keep it in a Folder where it's easily accessible from your terminal. Alt text
  9. In the Network Settings section, select Allow HTTPS traffic from the internet and Allow HTTP traffic from the internet Alt text
  10. Configure the storage requirements as you like, but we will be using 20 GiB gp3 configuration
  11. Select Launch Instance in the Summary section: Alt text
  12. You can now see your EC2 instance, in the Instances list: Alt text
  13. Port 8080 was added to the security group Alt text
  14. Select Connect, and choose SSH Client to get the details of the remote SSH connection. Alt text
  15. This is where the downloaded Identity file from the Key Pair created is needed. I opened up the terminal and:
ssh -i "Jenkins CI Server.pem" [email protected]

and connection to the EC2 instance was established.

Jenkins Installation

I installed Jenkins as per the official documentation at https://www.jenkins.io/doc/tutorials/tutorial-for-installing-jenkins-on-AWS/ as follows:

  1. Install OpenJDK Java Runtime Environment (JRE) 17:
sudo yum update –y
sudo wget -O /etc/yum.repos.d/jenkins.repo \
    https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
sudo yum upgrade
sudo dnf install java-17-amazon-corretto -y
  1. Install Jenkins LTS:
sudo yum install jenkins -y
  1. Enable the Jenkins service:
sudo systemctl enable jenkins
  1. Start the Jenkins service:
sudo systemctl start jenkins
  1. That's it setting up your CI/CD server, you can now access it using the public IP http://51.20.35.190:8080/. NOTE: SSL has not been enabled. Alt text
  2. You can find the administrator password at /var/jenkins_home/secrets/initialAdminPassword
  3. Run: cat /opt/jenkins/home/secrets/initialAdminPassword and copy the contents, and paste in to the password field.
  4. Select Install Suggested Plugins: Alt text
  5. As the setup progresses, you will be presented with this page: Alt text
  6. After the plugins installation completes, fill the Admin user information Alt text
  7. Choose the instance URL, we will use the public IP of the AWS instance, which will be filled in by default: Alt text
  8. Select start using Jenkins, and you will be signed in, and presented with the home page Alt text

Docker Installation

After establishing an SSH connection to your EC2 instance, here is where Docker will be installed. We install docker so that it can be used with jobs that need it. In my case this were the steps followed:

  1. Install the Docker package:
sudo yum install docker -y
  1. Added the jenkins user to the docker group
sudo usermod -aG docker jenkins