1 of 85

S3-Pipelines 02

DevOps Easy Learning

Application: Stomer

2 of 85

Problem to solve

Deploy and setup the application STOMER in all environments using robust automation

3 of 85

Core Areas pipelines

1- Development

2- Testing (QA)

3- Pre-production

4- Production

4 of 85

Requirements from Customer

1- High availability

2- zero downtime

3- Biweekly deployment

4- On demand scalability

5 of 85

Requirements from Development team

1- Provide an automated pipeline to build and test branches individually and provide notification to slack for any failure

2- Provide a sidekick quick testing pipeline with manual intervention, the pipeline should be capable of taking as input the branch name and deploy

3- Provide an automated pipeline to build test and deploy the main branch (develop) provide all build status notification to slack

4- Provide a 5 min deployment warning to user about upgrade.

5- Provide a Jenkins job capable of taking as input the branch name and tag , that will build, push images to dockerHub, tag the git branch and commit., with slack notification

6 of 85

Requirements from Quality Assurance (Testing) team

1- Provide a platform that will be capable to taking as input release tag from dev and perform some test ------- pipeline

2- provide a pipeline that will scan and test image provided

3- Provide and announcement job that will describe the state of the images with go-no-go to pre production. ------ slack notification

7 of 85

Requirements from Program management

1- Be mindful about resources cost. (cost optimization)

8 of 85

DevOps Expectation from Development team

1- What is the application made of

2- Language that each part of the application is written of

3- which library used (useful for base images)

4- app default port

5- how does the application run

6- demo of application running using libraries and binaries only

7- how to start the application

8- list of important file

9- important files locations and permission inside the container for the application to work properly

9 of 85

DevOps Expectation from QA team

1- list of tools to incorporate in their pipeline.

10 of 85

Requirements from Customer

1- High availability

2- zero downtime

3- Biweekly deployment unless otherwise specified

4- On demand scalability

5- Full backup all databases ( grand father, father, son)

6- The recovery time objective (RTO) 4h

7- Recovery Point Objective (RPO) 8h

8- Disaster recovery plan (DRP)

9- use AWS as cloud provider

10 - no requirements for self or manage service

11 of 85

Requirements from Database team

  1. Develop a comprehensive backup plan.

  • Perform effective backup management.

  • Perform periodic databases restore testing.

  • Have backup and recovery drafted and communicated to all stakeholders.

  • Have the disaster recovery plan (DRP) database portion drafted and documented.

  • Keep your knowledge and know-how on database and OS backup and recovery tools up to date.

  • store all backups on s3 bucket

12 of 85

Acceptance

Criteria

Security team requirements

13 of 85

Application image is secured

All OS-level dependencies are added via a package manager

Image runs as unprivileged user

Does not listen on privileged ports

Debug logs are disabled

All security features are enabled by default (NIST 800-53 CM-6)

All security-related configuration options are documented

Administrative APIs (e.g. metrics, admin consoles) listen on a dedicated port (NIST 800-53 SC-2)

Audit logs are written separately from application logs

14 of 85

Helm Chart is secure

Default values result in most-secure install/configuration

All security-related values are documented

Applications deploy with app-specific service accounts (not default/shared)

Service account permissions follow least-privilege principles

Secrets are used for all sensitive information

All workloads define appropriate Requests and Limits

15 of 85

Helm chart is highly compatible

Helm’s built-in Capabilities object is used to appropriately customize releases for target environments

16 of 85

High Availability

All workloads have well-defined liveness and readiness probes

All critical workloads are deployed with multiple replicas and topological skew

Workloads requiring persistent volumes are defined by StatefulSets

Stateful services perform replication using headless services (allowing multiple StatefulSets to coordinate)

All non-batch workloads have a PodDisruptionBudget defined

Helm releases are managed separately from application images and support RollingUpdate deployments

17 of 85

Others requirements

Critical observability metrics are exposed via Datadog endpoints

Pod/Service Monitors are defined

Alerting thresholds are defined

18 of 85

19 of 85

Devops team : GET FAMILIAR WITH PROJECT

20 of 85

Devops team REVIEW: MANAGEMENT REQUIREMENTS

Brainstorm in couple of strategies we can implement to save cost.

21 of 85

Devops team planning: MANAGEMENT REQUIREMENTS

Goal reduce the cost:

1- use on demand VM on Jenkins

2- use on demand container as much as possible

3- Carefully select resources involved into the process

4- use docker compose in place maybe in dev or testing areas if possible

22 of 85

Devops team REVIEW: DEVELOPMENT REQUIREMENTS

1- Provide an automated pipeline to build and test branches individually and provide notification to slack for any failure Multibranch pipeline integrated with slack.

2- Provide a sidekick quick testing pipeline job with manual intervention, the pipeline should be capable of taking as input the branch name and deploy – Parameterized pipeline (string).

3- Provide an automated pipeline job to build test and deploy the main branch (develop) provide all build status notification to slack Pipeline job set with webhook and integrate with slack.

4- Provide a 5 min deployment warning to user about upgrade. — Notify all users about upgrade (software change) add a sleep stage on pipeline indicated on 3.

5- Provide a Jenkins job capable of taking as input the branch name and tag , that will build, push images to dockerHub, tag the git branch and commit., with slack notification – Parameterized pipeline (string & choice & boolean) job to build and tag images.

23 of 85

Devops team planning: DEVELOPMENT REQUIREMENTS

Jenkins:

  1. Install require plugin

  • create require credentials

  • create the project as a folder ( Name Stormer)

  • create env as folder

  • create all jobs

  • write all jenkinsfiles

  • Perform functional test on all jobs.

24 of 85

Devops team REVIEW:

SECURITY REQUIREMENTS

All OS-level dependencies are added via a package manager —---- Use package manager only to install packages (dockerfile, VMs)

Image runs as unprivileged user —---- drop root user in dockerfile ( example USER S3)

Does not listen on privileged ports —-- Do not use port under 1024

Debug logs are disabled —-- pass flag debug: false into all k8s workload

All security features are enabled by default (NIST 800-53 CM-6) – go online and read

All security-related configuration options are documented —--------- create documentation for security

Administrative APIs (e.g. metrics, admin consoles) listen on a dedicated port (NIST 800-53 SC-2) – go online and read

Audit logs are written separately from application logs – go online and read

25 of 85

Devops team REVIEW:

SECURITY REQUIREMENTS

Default values result in most-secure install/configuration – make is very secure

All security-related values are documented — write documentation on security

Applications deploy with app-specific service accounts (not default/shared) —-- create service account for each workload

Service account permissions follow least-privilege principles —- Only assign permissions that a user or application is entitled to nothing less nothing more

Secrets are used for all sensitive information — create secret if need be

All workloads define appropriate Requests and Limits – set cpu and memory usage

26 of 85

Devops team planning: SECURITY REQUIREMENTS

Dockerfile:

  1. Only use apt, yum to install packages
  2. add a user and use that user as default user
  3. only use and expose ports that are above 1024

Kubernetes:

set debug to false into all k8s workloads manifest

create service account for each workload

set appropriate permission on service accounts

create secret file instead of using env variable in workloads

set cpu and memory usage for each workloads

create probe for all workloads

set replicas, PDB on all workloads

only use statefulset for DB and enable headless

use RollingUpdate upgrade strategy

27 of 85

Devops team REVIEW:

SECURITY REQUIREMENTS

Helm’s built-in Capabilities object is used to appropriately customize releases for target environments —-- create values file per environment.

28 of 85

Devops team planning: SECURITY REQUIREMENTS

Helm:

  1. create all helm charts
  2. create a single value file per env
  3. manage chart and app version in Chart.yaml

29 of 85

Devops team REVIEW:

SECURITY REQUIREMENTS

All workloads have well-defined liveness and readiness probes —- add liveness and readiness probes to deployment, statefulset, Deamonset

All critical workloads are deployed with multiple replicas and topological skew —- Set replicas to at least 2 and and add topological skew to deployment, statefulset, Daemonset

Workloads requiring persistent volumes are defined by StatefulSets —---- deploy all DB by statefulset

Stateful services perform replication using headless services (allowing multiple StatefulSets to coordinate) if having more than one 1 sts allow healess and enable communication between

All non-batch workloads have a PodDisruptionBudget defined add PDB to all workloads

Helm releases are managed separately from application images and support RollingUpdate deployments – appversion and chart version manage separately and all deployment strategy be RollingUpdate

30 of 85

Devops team REVIEW:

SECURITY REQUIREMENTS

Critical observability metrics are exposed via Datadog endpoints

Pod/Service Monitors are defined

Alerting thresholds are defined

Monitor all infrastructures and applications and services using datadog

31 of 85

Devops team REVIEW: DB TEAM REQUIREMENTS

  • Develop a comprehensive backup plan. —- done after
  • Perform effective backup management. —- done after
  • Perform periodic databases restore testing. —- done after
  • Have backup and recovery drafted and communicated to all stakeholders. —- done after
  • Have the disaster recovery plan (DRP) database portion drafted and documented. —- done after
  • Keep your knowledge and know-how on database and OS backup and recovery tools up to date. —- done after
  • store all backups on s3 bucket —- done after

32 of 85

Devops team planning: DB TEAM REQUIREMENTS

  • Develop a comprehensive backup plan. —- done after
  • Perform effective backup management. —- done after
  • Perform periodic databases restore testing. —- done after
  • Have backup and recovery drafted and communicated to all stakeholders. —- done after
  • Have the disaster recovery plan (DRP) database portion drafted and documented. —- done after
  • Keep your knowledge and know-how on database and OS backup and recovery tools up to date. —- done after
  • store all backups on s3 bucket —- done after

33 of 85

Devops team REVIEW: CUSTOMER TEAM REQUIREMENTS

1- High availability —-- always available no matter what

2- zero downtime —--- chose a upgrade strategy that does not make the app unavailable

3- Biweekly deployment —- new release or feature added biweekly

4- On demand scalability —--- auto scaling alone

34 of 85

Devops team planning: CUSTOMER TEAM REQUIREMENTS

High availability:

HA cluster

cross region replication

use cluster as much as possible

zero downtime:

blue green

canary

rollingUpdate.

Biweekly deployment:

make sure the infrastructure is ready for new release all the time

On demand scalability:

add HPA to all deploy or statefulset

35 of 85

https://docs.google.com/spreadsheets/d/1XF-M8k_OoMxrP6Zsl1VS2d3SkWM3d-9dM1FNhnBqlgc/edit#gid=0

https://drive.google.com/drive/folders/1tQiHZp4vJdd8snVz1C87xkKAaHPmmQ_U?usp=sharing

36 of 85

Devops At Work: Infrastructure planning

37 of 85

Devops At Work: Infrastructure planning

Tool that maybe used:

CICD:

1- Jenkins

REGISTRY:

1- Nexus

2- Harbor

ORCHESTRATION:

1- kubernetes (EKS)

2- Helm

MONITORING:

- datadog

DEPLOYMENT TOOL:

- ArgoCD

COMMUNICATION:

- slack

CODE SCANNING:

- SonarQube

CLOUD:

- AWS

VERSION CONTROL:

- Gitlab

CONTAINER MANAGEMENT:

- Docker-compose

CONTAINERIZATION:

- Docker

BUILD TOOL:

- maven

- golang

Tool that maybe used:

CICD:

1- gitlab

REGISTRY:

1- gitlab-CR

2- docker Hub

MONITORING:

- cloudwatch

DEPLOYMENT TOOL:

- Flux

CODE SCANNING:

- Veracode

VERSION CONTROL:

- Github

CONTAINER MANAGEMENT:

- ECS

BUILD TOOL:

- gradle

Tool that maybe used:

CICD:

1- Bambo

REGISTRY:

- ECR

38 of 85

List tools and their functionality

Code repos

Version control

containerization

Image repos

Continue integration

notification

Image repos

Code report

Code analysis

Continue deployment

Kubernetes package manager

Container orchestration

monitoring

39 of 85

Devops At Work: SOURCE CODE REPOSITORY

https://github.com/devopseasylearning/S3-projects/tree/develop/stormer-project02

40 of 85

Application Architecture

The application has been deliberately over-engineered to generate multiple de-coupled components. These components generally have different infrastructure dependencies, and may support multiple "backends"

41 of 85

Devops At Work: code review planning

JAVA:

- build with maven

GO:

- build with golang

NODE:

- research for now

NGINX:

- research for now

42 of 85

Devops At Work: DevOps Files planning

FILES:

- Dockerfiles

- Jenkinsfile

- Helm Chart

- Docker-compose file

- gitlab ci file

- Sonarqube Property file

- scripts

- config files

43 of 85

Devops At Work: Tools Adopted

DEPLOYMENT TOOL:

- ArgoCD

COMMUNICATION:

- slack

CODE SCANNING:

- SonarQube

CLOUD:

- AWS

CICD:

1- Jenkins

REGISTRY:

1- Nexus

2- Harbor

ORCHESTRATION:

1- kubernetes (EKS)

2- Helm

MONITORING:

- datadog

VERSION CONTROL:

- Github

CONTAINER MANAGEMENT:

- Docker-compose

CONTAINERIZATION:

- Docker

BUILD TOOL:

- maven

- golang

44 of 85

Devops At Work: Tools list planning

CICD:

1- Jenkins ------ install and configure plugins

REGISTRY:

1- Nexus -------- Launch and configure nexus server

ORCHESTRATION:

1- kubernetes (EKS) ------- Launch and configure EKS

2- Helm ----------------- NOT need will be ran by argocd

MONITORING:

- datadog ---------------- install and configure in k8s and create monitors

DEPLOYMENT TOOL:

- ArgoCD ------------------- install and configure in k8s

COMMUNICATION:

- slack ------------------- create a channel

CODE SCANNING:

- SonarQube ---------------- create quality gate for the projects

CLOUD:

- AWS ----------------- provision ressources

VERSION CONTROL:

- Github ----------------- configure the repo

CONTAINER MANAGEMENT:

- Docker-compose ------------ launch and configure on a VM

CONTAINERIZATION:

- Docker ------------ Install where required

BUILD TOOL:

- maven ---------- prebuild maven image

- golang ----------- prebuild golang image

45 of 85

Devops At Work: Launch all tools

Code repos

Version control

containerization

Image repos

Continue integration

notification

Image repos

Code report

Code analysis

Continue deployment

Kubernetes package manager

Container orchestration

monitoring

46 of 85

Devops At Work: Tools connection planning

Github

Jenkins

PagerDuty

Dockerhub

Sonar-cli

Sonarqube

maven

Golang

docker

Argocd

EKS

datadog

docker-compose

Helm

Slack

Person on call

47 of 85

Devops At Work: DEV WORK

48 of 85

Devops At Work: MAJOR DEVOPS FILES

FILES:

- Dockerfiles

- Jenkinsfile

- Helm Chart

- Docker-compose file

- gitlab ci file

- Sonarqube Property file

- scripts

- config files

Deploy on EKS

49 of 85

Test: go test

Test: maven test

Build .war

Build .exe

DEVELOPMENT PIPELINE (When pull request merged to develop branch)

1

2

6

5

4

3

7

8

9

14

12

13

11

17

16

15

18

10

1

2

3

50 of 85

DEVELOPMENT PIPELINE (When pull request merged to develop branch)

A pull request (PR) is merged in the develop branch (develop is the main branch for development and accept only code change by pull request)

notice the change on stormer repository via a preset webhook then clone the repository

Jenkins use the docker agent to launch a golang container to scan the all go code

1

2

Jenkins send build start notification on

3

4

Jenkins use the docker agent to launch a container to scan the all code

5

51 of 85

DEVELOPMENT PIPELINE (When pull request merged to develop branch)

use the docker agent to launch container to scan the code and the scan result sent back to

sent the build report to to be compared with quality gate

Jenkins use the docker agent to launch containers to build an artifact

6

7

sent the code analysis result back to

8

9

Jenkins use the docker agent to launch containers to build an artifact

10

52 of 85

DEVELOPMENT PIPELINE (When pull request merged to develop branch)

read to build all docker then push all of them to

Jenkins the charts on then update value.yaml file with new image tag

11

Jenkins commit back the new charts back into

12

13

notice the change on the on helm charts located on

14

53 of 85

DEVELOPMENT PIPELINE (When pull request merged to develop branch)

Invoke

15

to deploy in to

to deploy pull docker from

17

16

is available on the browser for

18

54 of 85

DEVELOPMENT PIPELINE (When pull request merged to develop branch)

agent notice and incident on the cluster and notify

ag notify the devops engineer on call by

ag notify the devops team on

1

2

3

55 of 85

Test: go build

Test: maven test

Build .war

Build .exe

DEVELOPMENT PIPELINE (When a code is changed on all branches except develop)

1

2

6

5

4

3

7

8

9

11

10

This pipeline on make sure an image can be built from the change made on the code

56 of 85

DEVELOPMENT PIPELINE (When pull request merged to develop branch)

a new branch is created or a commit is made to on of the branch

notice the change on stormer repository via a preset webhook the clone the repository

Jenkins use the docker agent to launch a golang container to scan the all go code

1

2

Jenkins send build start notification on

3

4

Jenkins use the docker agent to launch a container to scan the all code

5

57 of 85

DEVELOPMENT PIPELINE (When pull request merged to develop branch)

use the docker agent to launch container to scan the code and the scan result sent back to

sent the build report to to be compared with quality gate

Jenkins use the docker agent to launch containers to build an artifact

6

7

sent the code analysis result back to

8

9

Jenkins use the docker agent to launch containers to build an artifact

10

58 of 85

DEVELOPMENT PIPELINE (When pull request merged to develop branch)

read to build all docker ONLY no push required

11

59 of 85

5

4

3

2

1

DEVELOPMENT PIPELINE (build and push specific tag )

This pipeline is used to tag image and push to Nexus when everything is ok on dev side

60 of 85

Test: go build

Test: maven test

Build .war

Build .exe

DEVELOPMENT PIPELINE (Deploy a specific branch using K8S )

1

5

4

3

2

6

7

8

13

11

12

10

16

15

14

17

9

1

2

3

61 of 85

DEVELOPMENT PIPELINE (Deploy a specific branch using Docker-compose )

1

3

4

2

5

6

7

8

62 of 85

Devops At Work: QA WORK

63 of 85

Devops At Work: MAJOR DEVOPS FILES

64 of 85

1

4

3

2

5

QA PIPELINE

65 of 85

Devops At Work: PREPROD WORK

66 of 85

Devops At Work: MAJOR DEVOPS FILES

67 of 85

PREPROD PIPELINE

5

2

5

3

4

8

7

6

9

1

2

3

1

68 of 85

Devops At Work: PROD WORK

69 of 85

Devops At Work: MAJOR DEVOPS FILES

70 of 85

PROD PIPELINE

2

5

3

4

8

7

6

9

1

2

3

1

71 of 85

Devops At Work: DB WORK

72 of 85

Devops At Work: MAJOR DEVOPS FILES

73 of 85

1

3

2

4

DB PIPELINE automate backup

74 of 85

1

4

2

3

DB PIPELINE Restore backup

75 of 85

https://github.com/devopseasylearning/stomer/tree/main/src

CODE URL

76 of 85

77 of 85

Application Architecture

The application has been deliberately over-engineered to generate multiple de-coupled components. These components generally have different infrastructure dependencies, and may support multiple "backends"

78 of 85

Application Architecture

The application has been deliberately over-engineered to generate multiple de-coupled components. These components generally have different infrastructure dependencies, and may support multiple "backends"

79 of 85

Explain the whole pipeline scenario 01

80 of 85

Explain the whole pipeline scenario 02

81 of 85

Explain the whole pipeline scenario 03

82 of 85

Issues encountered while building the pipeline

No

Issue encountered

How did you fix it ?

83 of 85

Issues encountered while building the pipeline

No

Issue encountered

How did you fix it ?

84 of 85

Issues encountered while building the pipeline

No

Issue encountered

How did you fix it ?

85 of 85

Take personal notes here