This capstone project showcases the use of several CI/CD tools and cloud services covered in the program Udacity - AWS Cloud DevOps Engineer.
This project "operationalize" a sample python/flask demo app "hello", using CircleCI and a Kubernetes(K8S) cluster deployed in AWS EKS(Amazon Elastic Kubernetes Services):
- In a CircleCI pipeline, we lint the project's code, build a Docker image and deploy it to a public Docker Registry: Docker Hub
- Then in an AWS EKS cluster, we run the application
- Later, we promote to production a new app version using a rolling update strategy
All the project's tasks are included in a Makefile, which uses several shell scripts stored in the bin directory.
Using a CI/CD approach, we build a Docker image and then run it in a Kubernetes cluster.
The project includes the following main tasks:
- Initialize the Python virtual environment:
make setup
- Install all necessary dependencies:
make install
- Test the project's code using linting:
make lint
- Lints shell scripts, Dockerfile and python code
- Create a Dockerfile to "containerize" the hello application: Dockerfile
- Deploy to a public Docker Registry: Docker Hub the containerized application
- Deploy a Kubernetes cluster:
make eks-create-cluster
- Deploy the application:
make k8s-deployment
- Update the app in the cluster, using a rolling-update strategy:
make rolling-update
- Delete the cluster:
make eks-delete-cluster
The CirclCI pipeline(config.yml) will execute the following steps automatically:
make setup
make install
make lint
- Build and publish the container image
To verify that the app is working, write your deployment's IP into your browser using port 80, like
http://localhost:80
or http://LOAD_BALANCER_IP:80
(according to your environment).
Alternatively, you can use curl
: curl localhost:80
or curl LOAD_BALANCER_IP:80
- Circle CI - Cloud-based CI/CD service
- Amazon AWS - Cloud services
- AWS EKS - Amazon Elastic Kubernetes Services
- AWS eksctl - The official CLI for Amazon EKS
- AWS CLI - Command-line tool for AWS
- CloudFormation - Infrastructure as Code
- kubectl - a command-line tool to control Kubernetes clusters
- Docker Hub - Container images repository service
The project uses circleci/docker orb,
so to be able to build
and publish
your images, you need to set up the following environment
variables in your CircleCI project with your DockerHub account's values:
- DOCKER_LOGIN
- DOCKER_PASSWORD
- Makefile: the main file to execute all the project steps, i.e., the project's command center!
- config.yml: to test and integrate the app under CircleCI
- hello.app: the sample python/flask app
- Dockerfile: the Docker image's specification file
- hello_cluster.yml: EKS cluster definition file
The following shell scripts are invoked from the Makefile
- eks_create_cluster.sh: creates the EKS cluster
- install_eksctl.sh: installs the eksctl tool
- install_hadolint.sh: installs the hadolint linter(for Dockerfiles) tool
- install_kubectl.sh: installs the kubectl tool to control K8S clusters
- install_shellcheck.sh: installs the shellcheck(for shell scripts) linter tool
- k8s_cleanup_resources.sh: deletes services and deployments in a K8S cluster
- k8s_deployment.sh: deploys and exposes a service in the K8S cluster