https://github.com/boods/UdacityDevOpsCapstone
I'm interested in playing the violin, and have been thinking about building an application for tracking practice progress. This project will setup a CI/CD pipeline for the first component of that application - a very basic python webapi, built using flask, to return a list of skills that can be practiced.
The target environment for deployments will comprise a VPN with two public subnets, an EKS cluster and nodegroup, and two bastion hosts (one in each subnet)
The pipeline will work as follows:
- Code will be checked into a github repo
- A Jenkins server, running on an EC2 will monitor changes in the repo, and trigger builds
- Jenkins will download the latest source
- Jenkins will run pylint on the python code, and hadolint on the dockerfile
- Jenkins will run the python unit tests
- On successful linting, the Jenkins will build a docker image and push it to dockerhub, with the 'latest' tag
- Finally, jenkins will perform a rolling update on the kubernetes cluster
The following diagram depicts the typical pipline flow:
The repo consists for the following:
- Jenkinsfile - the build pipline file used by the Jenkins instance
- skills.yaml - kubernetes manifest for the skills webserver
- skills-service.yaml - kubernetes manifest for the kubernetes load balancer
- skills/tests - python unit tests (test_skills.py)
- infrastructure/ - AWS cloudformation templates for setting up the target environment, and bash scripts to create, update and delete the environment
- skills/ - the python application (skills.py), Makefile, DockerFile, and requirements.txt (detailing python library dependencies)
Make a breaking change to the python code and check it into github:
Confirm that the build fails on the pylint step:
Fix the python error, but make a breaking change to the dockerfile and check that into git hub:
Confirm that the build is still failing, this time on the hadolint step:
Fix the dockerfile issue, commit the change and confirm that the linting is successful
And full deployment is working:
View the output with curl prior to deployment:
Make a small change to the skills.py to publish a new skill, and commit the change:
Confirm the rolling deployment is performed by Jenkins:
Confirm the output with curl after deployment - notice the additional skill appearing:
Perform a test where an EC2 instance in the cluster is taken offline, and a replacement instance started: