Jenkins-AWS-CICD - Implement Jenkins CI/CD with AWS CodeBuild and AWS CodeDeploy, build a python flask web application.

Overview

Jenkins CI/CD with AWS CodeBuild and AWS CodeDeploy

Continuous integration and continuous deployment for a python flask web application.

Architecture

Jenkins CI/CD with AWS CodeBuild and AWS CodeDeploy

Installation

1. Launch an EC2 instance as config host, clone repository from Github

    git clone https://github.com/dragonflly/Jenkins-AWS-CICD.git

    Repository folder tree:

  └── Jenkins-AWS-CICD/
      ├── application
      ├── cfn-template
      ├── iam-resource
      ├── images
      └── README.md

2. Create flask web application repository in Github

  • Create a new repository in your Gitbub account (Example: Jenkins-app)
  • Clone Jenkins-app
    git clone https://github.com/
   
    /Jenkins-app.git

   

two repo

  • Copy flask web application to Jenkins-app, then push
    cp -r Jenkins-AWS-CICD/application/* Jenkins-app
    cd Jenkins-app
    git add .
    git commit -m "flask web initial"
    git push

3. Create SSH keyPair

  • Create a KeyPair on AWS console (Example: KeyPair-us-east-1 in us-east-1)

4. Create a CFN templates S3 bucket and upload templates

  • Create a S3 bucket (Example: jenkins-cicd-cfn-templates in us-east-1)
    aws s3api create-bucket --bucket jenkins-cicd-cfn-templates --region us-east-1
  • Copy CFN templates to the S3 bucket
    aws s3 cp Jenkins-AWS-CICD s3://jenkins-cicd-cfn-templates/Jenkins-AWS-CICD --recursive

5. Create whole AWS infrastructure as Code (IaC) with CloudFormation

  • Create stack from AWS CloudFormation console, specify template source by Amazon S3 URL
    https://jenkins-cicd-cfn-templates.s3.amazonaws.com/Jenkins-AWS-CICD/cfn-template/cicd-Jenkins.yaml
  • Specify stack input parameter from console
    Stack name: Jenkins-cicd
    KeyPairName: KeyPair-us-east-1
    TemplateS3Bucket: jenkins-cicd-cfn-templates

      It will takes approximately 6 minutes, and CloudFormation stack Outputs tab:
Jenkins CICD AWS IaC

6. Unlock Jenkins server, and initialize Jenkins

  • SSH into JenkinsServer with IP address and KeyPair-us-east-1
    Jenkins Server

  • Get initialAdminPassword

    cat /var/lib/jenkins/secrets/initialAdminPassword
  • Copy the JenkinsServerAddr value (Example: 34.205.33.197:8080) from the CloudFormation stack Outputs tab, and paste it into browser

  • Paste initialAdminPassword into Administrator password, unlock Jenkins server Unlock Jenkins server

  • Install suggested plugins
    Install suggested plugins

  • Create First Admin User
    Create First Admin User

  • Waiting a few minutes, Jenkins will be ready!

7. Add Jenkins plugin

  • Click on Manage Jenkins, then Manage Plugins
  • Search Available and select the below plugins, then choose Install without restart
    AWS CodeDeploy
    AWS CodeBuild
    Http Request
    File Operations

choose plugin

  • Choose Restart Jenkins when installation is complete
    Restart Jenkins

  • It will take couple of minutes to download the plugins then restart

8. Create a Jenkins CICD project

  • Choose New Item
    Enter an item name (Example: Jenkins-CICD)
    Select Freestyle project
    Create Freestyle project

  • Under Source Code Management
    Choose Git
    Enter HTTPS of Jenkins-app.git into Repository URL
    Change Branch Specifier from master to main
    SCM config

  • Under Build Triggers
    Select Poll SCM
    Enter H/2 * * * * into Schedule, to poll GitHub every two minutes
    build trigger

  • Under Build Environment
    Select Delete workspace before build starts
    build environment

9. Add AWS CodeBuild

  • Under Build
    Select Add build step
    Choose AWS CodeBuild
    Add CodeBuild step

  • Under AWS Configuration
    Choose Manually specify access and secret keys
    Input AWS Access Key
    Input AWS Secret Key
    input AK SK

  • Under Project Configuration
    Enter AWS Region (Example: us-east-1)
    Enter CodeBuild Project Name, copy from CloudFormation Outputs tab
    Select Use Jenkins source
    project configuration

10. Add File Operation

  • Under Build
    Select Add build step
    Choose File Operation

  • Under File Operation
    Select File Delete
    file delete

  • Under File Delete
    Input asterisk, to delete all files which from Github after zip and upload
    Input asterisk

11. Add HTTP Request

12. Add File Operation

  • Under Build
    Select Add build step
    Choose File Operation

  • Under File Operation
    Select Add, then Unzip
    Select Add, then File Delete

  • Under Zip File
    Enter codebuild-artifact.zip into Zip File

  • Under File Delete
    Enter codebuild-artifact.zip into Include File Pattern
    file zip delete

13. Add AWS CodeDeploy

  • Under Post-build Actions
    Select Add post-build action
    Choose Deploy an application to AWS CodeDeploy
    add CodeDeploy

  • Under Deploy an application to AWS CodeDeploy
    Fill AWS CodeDeploy Application Name which copied from Outputs tab
    Fill AWS CodeDeploy Deployment Group which copied from Outputs tab
    Fill AWS CodeDeploy Deployment Config with CodeDeployDefault.OneAtATime
    Fill AWS Region (Example: us-east-1)
    Fill S3 Bucket which copied from Outputs tab
    CodeDeploy config

  • Select Deploy Revision

  • Choose Wait for deployment to finish
    deploy revision

  • Click SAVE to finish configuration

14. Build and check

  • Click Build Now
    Check Jenkins CICD progress
    build and deploy

  • CICD finished, copy ALBURL from Outputs tab, paste into browser
    Python flask web application should be
    falsk application

  • In flask application repository Jenkins-app
    Change background-color from blue to red in application/templates/Jenkins-page.html
    Commit change, trigger CI/CD in two minutes
    falsk application

License Summary

This code is made available under the MIT license. See the LICENSE file.

Supervisor process control system for UNIX

Supervisor Supervisor is a client/server system that allows its users to control a number of processes on UNIX-like operating systems. Supported Platf

Supervisor 7.6k Dec 31, 2022
Push Container Image To Docker Registry In Python

push-container-image-to-docker-registry 概要 push-container-image-to-docker-registry は、エッジコンピューティング環境において、特定のエッジ端末上の Private Docker Registry に特定のコンテナイメー

Latona, Inc. 3 Nov 04, 2021
This repository contains code examples and documentation for learning how applications can be developed with Kubernetes

BigBitBus KAT Components Click on the diagram to enlarge, or follow this link for detailed documentation Introduction Welcome to the BigBitBus Kuberne

51 Oct 16, 2022
Knock your images before these make you painful.

image-knocker Knock your images before these make you painful. Background One day, I had run my deep learning model training program and got off work

Yonghye Kwon 9 Jul 25, 2022
A Blazing fast Security Auditing tool for Kubernetes

A Blazing fast Security Auditing tool for kubernetes!! Basic Overview Kubestriker performs numerous in depth checks on kubernetes infra to identify th

Vasant Chinnipilli 934 Jan 04, 2023
A Kubernetes operator that creates UptimeRobot monitors for your ingresses

This operator automatically creates uptime monitors at UptimeRobot for your Kubernetes Ingress resources. This allows you to easily integrate uptime monitoring of your services into your Kubernetes d

Max 49 Dec 14, 2022
Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions

Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions

Arie Bregman 35.1k Jan 02, 2023
Coding For Entrepreneurs 100 Jan 01, 2023
Inferoxy is a service for quick deploying and using dockerized Computer Vision models.

Inferoxy is a service for quick deploying and using dockerized Computer Vision models. It's a core of EORA's Computer Vision platform Vision Hub that runs on top of AWS EKS.

94 Oct 10, 2022
Convenient tool to manage multiple VMs at once using libvirt

Convenient tool to manage multiple VMs at once using libvirt Installing To install the tool and its dependencies: pip install -e . Getting completion

Cedric Bosdonnat 13 Nov 11, 2022
Cado Response Integration with Amazon GuardDuty using AWS Lambda

Cado Response Integration with Amazon GuardDuty using AWS Lambda This repository contains a simple example where: An alert is triggered by GuardDuty T

Cado Security 4 Mar 02, 2022
Find-Xss - Termux Kurulum Dosyası Eklendi Eğer Hata Alıyorsanız Lütfen Resmini Çekip İnstagramdan Bildiriniz

FindXss Waf Bypass Eklendi !!! PRODUCER: Saep UPDATER: Aser-Vant Download: git c

Aser 2 Apr 17, 2022
Define and run multi-container applications with Docker

Docker Compose Docker Compose is a tool for running multi-container applications on Docker defined using the Compose file format. A Compose file is us

Docker 28.2k Jan 08, 2023
Caboto, the Kubernetes semantic analysis tool

Caboto Caboto, the Kubernetes semantic analysis toolkit. It contains a lightweight Python library for semantic analysis of plain Kubernetes manifests

Michael Schilonka 8 Nov 26, 2022
A basic instruction for Kubernetes setup and understanding.

A basic instruction for Kubernetes setup and understanding Module ID Module Guide - Install Kubernetes Cluster k8s-install 3 Docker Core Technology mo

648 Jan 02, 2023
This repository contains useful docker-swarm-tools.

docker-swarm-tools This repository contains useful docker-swarm-tools. swarm-guardian This Docker image is intended to be used in a multihost docker e

NeuroForge GmbH & Co. KG 4 Jan 12, 2022
Build and Push docker image in Python (luigi + docker-py)

Docker build images workflow in Python Since docker hub stopped building images for free accounts, I've been looking for another way to do it. I could

Fabien D. 2 Dec 15, 2022
A repository containing a short tutorial for Docker (with Python).

Docker Tutorial for IFT 6758 Lab In this repository, we examine the advtanges of virtualization, what Docker is and how we can deploy simple programs

Arka Mukherjee 0 Dec 14, 2021
Play Wordle from any Kubernetes cluster.

wordle-operator 🟩 ⬛ 🟩 🟨 ⬛ Play Wordle from any Kubernetes cluster. Using the power of CustomResourceDefinitions and Kubernetes Operators, now you c

Lucas Melin 1 Jan 15, 2022
Visual disk-usage analyser for docker images

whaler What? A command-line tool for visually investigating the disk usage of docker images Why? Large images are slow to move and expensive to store.

Treebeard Technologies 194 Sep 01, 2022