# Jenkins Learning
# Jenkis Terraform Architecture
# VPC
VPC Config
- IPv4 CIDR:
10.0.0.0/16
Subnets
Private Subnets x2
- Private Subnet 1:
- IPv4 CIDR:
10.0.2.0/24
- IPv4 CIDR:
- Private Subnet 2:
- IPv4 CIDR:
10.0.3.0/24
- IPv4 CIDR:
- Private Subnet 1:
Public Subnets x2
- Public Subnet 1:
- IPv4 CIDR:
10.0.0.0/24
- Auto Assign IP Address:
True
- IPv4 CIDR:
- Public Subnet 2:
- IPv4 CIDR:
10.0.1.0/24
- Auto Assign IP Address:
True
- IPv4 CIDR:
- Public Subnet 1:
Router Tables x3:
- Public Router Table:
- Routes Target -> From
0.0.0.0/0
toInternet Gateway
- Associations: Public Subnets
- Routes Target -> From
- Private Router Table 1:
- Routes Target -> From
0.0.0.0/0
toNAT Gateway
- Private Subnet 1
- Routes Target -> From
- Private Router Table 2:
- Routes Target -> From
0.0.0.0/0
toNAT Gateway
- Private Subnet 2
- Routes Target -> From
- Public Router Table:
Internet Gateway
Attached to VPC
Elastic IP IDs
- Associated to
Nat Gateways
Nat Gateways
- One per Public Subnet
Network ACL
- Associated with all 4 Subnets
- Inbound Rules:
- Source
0.0.0.0/0
- Rule Number100
- TypeAll traffic
- Source
- Outbound Rules:
- Source
0.0.0.0/0
- Rule Number100
- TypeAll traffic
- Source
Security Groups
- Load Balancer SG
- Inbound Rules:
HTTPS
-443
-0.0.0.0/0
- Outbound Rules:
8080
-JenkinsSecurityGroup
- Inbound Rules:
- Jenkins SG
- Inbound Rules:
TCP
-8080
-0.0.0.0/0
- Outbound Rules:
All traffic
-0.0.0.0/0
- Inbound Rules:
- Jenkins EFS
- Inbound Rules:
TCP
-2049
-JenkinsSecurityGroup
- Outbound Rules:
All traffic
-0.0.0.0/0
- Inbound Rules:
# EC2
Load Balancer
- Attributes:
- HTTP LB
- Internet-facing scheme
- Subnets:
Public Subnet 1
&Public Subnet 2
- Security Group:
Load Balancer SG
- Listener:
- HTTP 443
- Certification from DNS
- Forwarding:
- To
JenkinsTargetGroup
:- Target:
10.0.3.81
-8080
-
- Target:
- To
# Resources
# Install Jenkins
Install Java
sudo apt update
sudo apt install openjdk-8-jdk
Install Jenkins
sudo apt-get update
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > \
/etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
After installing run
sudo systemctl start jenkins
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
To run commands as sudo
:
vi /etc/sudoers
jenkins ALL=(ALL) NOPASSWD: ALL
# Things to Consider for Installation
- Make sure Jenkins user can run
sudo
commands. - Be mindful of the Terraform state.
- Get the right plugins and credentials in place.
- Make sure AWS Resources have the right accesses.