Scenario:

Mono-repo with multiple projects hosted on github.. We need a CI/CD setup for this, whenever a pull request is raised.

Inputs:

  • Code hosted on Github

Continuous Integration/CI server:

  • CI server shall merge incoming branch into master in its environment, when a pull request is made.
  • Run unit tests
  • Run integration tests
  • Gives an endpoint for the pull request owner to manually validate integration

Steps:

  • git merge
  • <code_base>
  • <code_base>
  • Bring up necessary infra
  • <integration_test> <code_base>
  • if all pass, push the binaries to artefact storage.

Continuous Delivery:

  • The server bakes the binaries into a ready to use AMI or image. This step shall also create auto-scaling group, launch template, etc. necessary for service to function for end user.

Steps:

  • Provision new AMI using packer, with latest binary from earlier step.
  • Invoke terraform script to create launch template, auto-scaling group, target group, etc.
  • It responds to jenkins server when the delivery is ready for deployment.

Continuous Deployment:

Note: Anywhere it says, “attach to load balancer” can be perceived as “registered to service discovery” for that architecture.

  • The server takes manual command from service owner, attaches the auto-scaling group to load balancer.
  • Allows user to terminate older deployment after a few minutes..Typically greater than time_taken_to_launch_server+time_taken_to_initialise_process+minimum_healthy_threshold*interval
  • Once done, notifies monitoring system about new deployment.

Steps:

  • Gets current autoscaling group id from above step
  • Adds them to defined load balancer
  • Awaits for load balancer stats on health, asks for termination
  • Terminates older infra upon confirmation