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.

Lima is an alternative to using Docker Desktop on your Mac.

lima-xbar-plugin Table of Contents Description Installation Dependencies Lima is an alternative to using Docker Desktop on your Mac. Description This

Joe Block 68 Dec 22, 2022
ServerStatus 云探针、多服务器探针、云监控、多服务器云监控

ServerStatus 云探针、多服务器探针、云监控、多服务器云监控 基于ServerStatus-Hotaru膜改版的套娃膜改版(实际上本README也是抄它的)。 主要将client改为通过http提交数据,以及将服务端换成了php以便减小部署成本(PHP is the best!) 默认图片

shirakun 16 Apr 14, 2022
Helperpod - A CLI tool to run a Kubernetes utility pod with pre-installed tools that can be used for debugging/testing purposes inside a Kubernetes cluster

Helperpod is a CLI tool to run a Kubernetes utility pod with pre-installed tools that can be used for debugging/testing purposes inside a Kubernetes cluster.

Atakan Tatlı 2 Feb 05, 2022
Containerize a python web application

containerize a python web application introduction this document is part of GDSC at the university of bahrain you don't need to follow along, fell fre

abdullah mosibah 1 Oct 19, 2021
gunicorn 'Green Unicorn' is a WSGI HTTP Server for UNIX, fast clients and sleepy applications.

Gunicorn Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX. It's a pre-fork worker model ported from Ruby's Unicorn project. The Gunicorn

Benoit Chesneau 8.7k Jan 08, 2023
Hackergame nc 类题目的 Docker 容器资源限制、动态 flag、网页终端

Hackergame nc 类题目的 Docker 容器资源限制、动态 flag、网页终端 快速入门 配置证书 证书用于验证用户 Token。请确保这里的证书文件(cert.pem)与 Hackergame 平台 配置的证书相同,这样 Hackergame 平台为每个用户生成的 Token 才可以通

USTC Hackergame 68 Nov 09, 2022
A colony of interacting processes

NColony Infrastructure for running "colonies" of processes. Hacking $ tox Should DTRT -- if it passes, it means unit tests are passing, and 100% cover

23 Apr 04, 2022
Get Response Of Container Deployment Kube with python

get-response-of-container-deployment-kube 概要 get-response-of-container-deployment-kube は、例えばエッジコンピューティング環境のコンテナデプロイメントシステムにおいて、デプロイ元の端末がデプロイ先のコンテナデプロイ

Latona, Inc. 3 Nov 05, 2021
Deploy a simple Multi-Node Clickhouse Cluster with docker-compose in minutes.

Simple Multi Node Clickhouse Cluster I hate those single-node clickhouse clusters and manually installation, I mean, why should we: Running multiple c

Nova Kwok 11 Nov 18, 2022
HB Case Study

HB Case Study Envoy Proxy It is a modern Layer7(App) and Layer3(TCP) proxy Incredibly modernized version of reverse proxies like NGINX, HAProxy It is

Ilker Ispir 1 Oct 22, 2021
Apache Airflow - A platform to programmatically author, schedule, and monitor workflows

Apache Airflow Apache Airflow (or simply Airflow) is a platform to programmatically author, schedule, and monitor workflows. When workflows are define

The Apache Software Foundation 28.6k Jan 01, 2023
Docker Container wallstreetbets-sentiment-analysis

Docker Container wallstreetbets-sentiment-analysis A docker container using restful endpoints exposed on port 5000 "/analyze" to gather sentiment anal

145 Nov 22, 2022
Emissary - open source Kubernetes-native API gateway for microservices built on the Envoy Proxy

Emissary-ingress Emissary-Ingress is an open-source Kubernetes-native API Gateway + Layer 7 load balancer + Kubernetes Ingress built on Envoy Proxy. E

Emissary Ingress 4k Dec 31, 2022
CTF infrastructure deployment automation tool.

CTF infrastructure deployment automation tool. Focus on the challenges. Mirrored from

Fake News 1 Apr 12, 2022
CDK Template of Table Definition AWS Lambda for RDB

CDK Template of Table Definition AWS Lambda for RDB Overview This sample deploys Amazon Aurora of PostgreSQL or MySQL with AWS Lambda that can define

AWS Samples 5 May 16, 2022
Webinar oficial Zabbix Brasil. Uma série de 4 aulas sobre API do Zabbix.

Repositório de scripts do Webinar de API do Zabbix Webinar oficial Zabbix Brasil. Uma série de 4 aulas sobre API do Zabbix. Nossos encontros [x] 04/11

Robert Silva 7 Mar 31, 2022
A job launching library for docker, EC2, GCP, etc.

doodad A library for packaging dependencies and launching scripts (with a focus on python) on different platforms using Docker. Currently supported pl

Justin Fu 55 Aug 27, 2022
Build Netbox as a Docker container

netbox-docker The Github repository houses the components needed to build Netbox as a Docker container. Images are built using this code and are relea

Farshad Nick 1 Dec 18, 2021
Kubediff: a tool for Kubernetes to show differences between running state and version controlled configuration.

Kubediff: a tool for Kubernetes to show differences between running state and version controlled configuration.

Weaveworks 1.1k Dec 30, 2022
NixOps is a tool for deploying to NixOS machines in a network or cloud.

NixOps NixOps is a tool for deploying to NixOS machines in a network or the cloud. Key features include: Declarative: NixOps determines and carries ou

Nix/Nixpkgs/NixOS 1.2k Jan 02, 2023