This is a CI/CD pipeline using CircleCI that automatically deploy ASP.NET Core Application to EKS Cluster.
The project's goal is to apply the skills and knowledge that I developed throughout the Cloud DevOps Nanodegree program. In this project I did:
- Working in AWS
- Using CircleCI to implement Continuos Integration and Continuos Deployment
- Building pipelines
- Working with Ansible and CloudFormation to deploy clusters
- Building Kubernetes clusters
- Building Docker containers in pipelines
Technology | Description | Link |
---|---|---|
AWS | Online platform that provides scalable and cost-effective cloud computing solutions | https://aws.amazon.com// |
C# | High Level, Mutli-paradigm, Compiled Language | https://docs.microsoft.com/en-us/dotnet/csharp/ |
.NET 6.0 | The merger of .NET Framework and .NET Core, Open source, Cross platform | https://docs.microsoft.com/en-us/dotnet/ |
Docker | Open platform for developing, shipping, and running applications | https://docs.docker.com/ |
Kubernetes | Open-source system for automating deployment, scaling, and management of containerized applications | https://kubernetes.io/ |
Ansible | IT automation tool that automates cloud provisioning configuration management, application deployment, infra-service orchestration and many other IT needs | https://www.ansible.com/ |
CircleCI | Continuos integration & delivery platform that helps the development teams to release code rapidly and automate the build, test, and deploy | https://circleci.com/ |
- Create the CircleCI account
- Create a Github repository
- Set up a Dockerhub account and repository
- Create an AWS - IAM user with the policies suggested on the official eksctl website as Minimum IAM policies
I used source code from my other interesting course Architecting ASP.NET Core 3 Applications: Best Practices. This app is building a ticket management system for events. The backend uses the ASP.NET Core Restful API, and the frontend uses Blazor WebAssembly.
I used AWS Cloudformation to deploy the Kubernetes Cluster. I have researched and customized based on these templates and documents:
- amazon-eks-fully-private-vpc.yaml
- amazon-eks-nodegroup.yaml
- AWS EKS: Managed setup with CloudFormation
I decided to split it into 4 cloudformation stacks:
- Network, create network infrastructure that the the EKS cluster will reside in.
- EKS (Elastic Kubernetes Service) for deploying a Kubernetes cluster.
- NodeGroup is used to create actual worker nodes. For greater security, these nodes are linked to private subnets.
- Management is needed to configure and manage the EKS Cluster and its deployments and services. These EC2 instances are connected to public subnets. Also used to connect and troubleshoot issues that happen in worker nodes (private subnets).
After deploying the infrastructure, I used Ansible to configure management hosts.
-
Install AWS CLI and Kubectl.
-
Run
aws eks update-kubeconfig --region <<region-code>> --name <<cluster name>>
to fetch kubectl config -
Run
kubectl apply -f <<path to defined resource template.yaml>>
to create Kubernetes resouces -
Run
kubectl set image deployments/<<deployment name>> <<container name>>=<<docker image>>
to apply new docker image for deployment -
Run
kubectl rollout status deployments/<<deployment name>>
to check deployment status -
Run
kubectl get svc <<name of service>>
to view information of service
I have used CircleCI to define pipelines including:
- Linting
- Code building
- Unit testing
- Integration testing
- Build and push docker image to Docker Hub
- Slack notify when pipeline failed, deployment success
After the EKS-Cluster has been successfully configured using Ansible within the CI/CD Pipeline, I checked the deployment and service as follows:
$ kubectl get deploy,svc,pods
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/capstone-project-backend-deployment 2/2 2 2 31h
deployment.apps/capstone-project-frontend-deployment 2/2 2 2 31h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/capstone-project-backend-service LoadBalancer 10.100.50.170 ad202d75462044bcc92cfafc1cfef81b-2093070563.us-east-1.elb.amazonaws.com 80:30734/TCP 31h
service/capstone-project-frontend-service LoadBalancer 10.100.97.87 a6cd963bdc9c14fa282301cc33b22f8e-1955870495.us-east-1.elb.amazonaws.com 80:30862/TCP 31h
service/kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 31h
NAME READY STATUS RESTARTS AGE
pod/capstone-project-backend-deployment-5d7f8cc6f4-d2wjq 1/1 Running 0 6m44s
pod/capstone-project-backend-deployment-5d7f8cc6f4-sbns5 1/1 Running 0 6m48s
pod/capstone-project-frontend-deployment-d895f5db8-fvp7d 1/1 Running 0 6m38s
pod/capstone-project-frontend-deployment-d895f5db8-qlpbw 1/1 Running 0 6m9s
Public Loader Balancer's DNS: http://ad202d75462044bcc92cfafc1cfef81b-2093070563.us-east-1.elb.amazonaws.com/swagger/index.html