Skip to content

Automation to deploy Jenkins on AWS Fargate with Auto Scaling and AWS EFS. Also, this will deploy the core infrastructure, such as VPC, subnets, NAT, IGW, etc.

License

Notifications You must be signed in to change notification settings

lessandro-ugulino/aws-fargate-jenkins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Index

Introduction

This pipeline via automation will deploy Jenkins on a AWS Fargate also the core infraestructure to support it.

Jenkins - an open source automation server which enables developers around the world to reliably build, test, and deploy their software.

Diagram

The below diagram shows the AWS resources.

Diagram

Requirements

  1. These tools were installed:
  1. Update the file group_vars/all/common.yml accordingly.
---
cloudformation:
  check_mode_override: false
  region: ap-southeast-2
  create_changeset: true
  state: present

Route53:
  HostedZoneName: "ugulino.com."
  RecordName: "jenkins.ugulino.com"
  CertificateId: "5eaa197e" # your ACM Id

ECS:
  ASG_MinCapacity: 1
  ASG_MaxCapacity: 10

Ansible

Playbook Command

The file deploy-role.yml will deploy each role required to deploy this project.

---
- hosts: localhost
  roles:
    - vpc-baseline
    - ecs-cluster
    - ecs-jenkins
    - route53

The below command will execute the tasks defined on the above file.

ansible-playbook deploy-role.yml -vvv

Output

You can verify the deployment via ansible output or via AWS CloudFormation console.

  • Ansible Output:

AnsibleOutput

  • AWS CloudFormation Console:

AWSCF

AWS

Network

Network

ECS Cluster

ecs-cluster

AWS EFS

aws-efs

ECS Jenkins

aws-ecs-jenkins

Domain

An 'A' record was created pointing to Application Load Balancer via automation.

ARecord

Application

Web Console

You can access and setup Jenkins accessing the URL https://jenkins.ugulino.com (be aware that this is my domain, probably you've setup a different one)

web-console

ECS Auto Scaling

Automatic scaling is the ability to increase or decrease the desired count of tasks in your Amazon ECS service automatically.

Running the below command, we can stress the environment and then test the ASG.

autocannon

autocannon -c 200 -d 200 -m GET https://jenkins.ugulino.com

As soon as the CPU will be consumed more than 50%, the ECS tasks will scale up.

asg_increase

asg_increase2

asg_increase3

Destroy

Basically, to destroy this deployment you can either do it via ansible command or AWS CloudFormation.

Via Ansible

Change the file group_vars/all/common.yml

cloudformation:
  check_mode_override: false
  region: ap-southeast-2
  create_changeset: true
  state: absent # this is the value you need to change to destroy the stacks

Execute the command:

ansible-playbook deploy-role.yml -vvv

Via CloudFormation

Select the CloudFormation stack, click delete, and then Delete stack.

destroy

About

Automation to deploy Jenkins on AWS Fargate with Auto Scaling and AWS EFS. Also, this will deploy the core infrastructure, such as VPC, subnets, NAT, IGW, etc.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages