GitHub Actions is an open-source CI-CD tool that is an extended feature of GitHub. It automates software workflows with world-class CI-CD. Build, Test, and deploy your code from GitHub.
How GitHub Actions Work
- Workflows: Workflows are automated processes defined in the YAML file and triggered on an event like Push.
- Events: Events are operations that change the repository, like Pull Operations and Push Operations.
- Jobs: Within Workflow, we can define one or more Jobs, such as a Build, Test, or Deploy Job.
- Actions: Actions define the Workflow’s inputs, outputs, and main entry points.
Kubernetes is an Open Source Container Orchestration tool that automates Containerized Applications’ deployment, scaling, and management. Kubernetes was invented by Google in 2013 and was handed over to CNCF (Cloud Native Computing Foundation), which is a part of the Linux Foundation. However, Kubernetes is not handled by a single entity; instead, it is a contribution from a worldwide community or developers.
EKS is a fully managed AWS Kubernetes Service that allows you to run your application on serverless infrastructures. It requires installing and operating the Kubernetes Cluster, which can be time-consuming and complex. Instead of configuring the Kubernetes Cluster, EKS lets you focus on deploying the application.
What Problems are Solved by Container Orchestration Tool
- Manual Deployment: Manual Deployment of Applications across multiple Environments, Infrastructure Monitoring, and Network Configuration can be Solved by Container Orchestration Tools.
- Scaling: Kubernetes supports auto-scaling, which scales out Infrastructure Properties like CPU RAM, etc.
- Application Lifecycle Management: Handling application updates, rollouts, rollbacks, and failure recovery in a reliable, consistent, and efficient manner.
- Monitoring And Troubleshooting: The Container Orchestration tool allows you to monitor the application’s health and troubleshoot the debugging failures.
How Kubernetes Solves These Issues
- Configuration: Declarative Configuration can easily allow the user to define the desired state of the Application through the YAML File.
- Container Orchestration: Automates the Deployment, Scaling, and health check of Containers, which means K8s automates the lifecycle of Containers.
- Self-Healing Mechanisms: K8s also have a property like self-healing, which means that suppose one of the containers fails for any reason. Automatically, a new container can start in place of a failed container.
- Scalability: It enables the horizontal scaling of the application by adding or removing the pods based on application demand.
Architecture Diagram
In this Architecture Diagram, we have set up Git Repository and uploaded the application data along with the .github/workflow folder.
- .github/Workflow: in this folder, we have mentioned our CI-CD workflow in yaml file(GitHub-actions-ci.yml )
When we push changes to the main branch, the GitHub Actions workflow triggers and executes all the commands mentioned in the Workflow. - IAM Access: We have provided access to GitHub Actions, which will connect AWS Cloud, mainly AWS ECR and AWS EKS services.
- Amazon ECR: It is a Container Registry service. When workflow triggers, the Docker Image is stored in the ECR Repository.
- Amazon EKS: EKS Cluster has been created in Amazon EKS service, a Compute service. EKS pulls the docker image from ECR and Deploys it on the EKS Cluster.
We received the email notification for the successful completion of the workflow.
Installations Steps
Step 1: Create an EKS Cluster
To create a Cluster, we must Launch EC2 Instance in the us-east-2 region.
To create a cluster and provide access, follow the instructions in the link below:
https://github.com/prafulitankar/github-action-eks/blob/main/.github/workflows/eks-cluster-setup.md
Step 2: Create an IAM User
Create an IAM User and provide the ECR and EKS Access to the User, which is communicated to GitHub and AWS Cloud.
Generate an Access Key and Secret key for that Particular User, and don’t forget to store it somewhere.
Step 3: Create an ECR Repo in us-east-2
Remember, this is where we stored Docker Images.
Step 4: Create a GitHub Repository
You can clone my GitHub Repository: https://github.com/prafulitankar/github-action-eks.git
Step 5: Set up Repository Secrets
The IAM user’s Access Key and Secret Key will communicate between GitHub Action and AWS Cloud.
Step 6: Enable Email Notifications
We will receive an email notification on every Push in the main branch at the mentioned email address.
Step 7: Deploy the Application
Deployment of application trigger once code pushed into the main branch.
Some IAM Access is given at the Cluster Level.
Once we have successfully deployed the Application on EKS Cluster, we will get an email notification.
Output:
Conclusion
GitHub is a CVS that allows us to store Source Code and GitHub Actions, an extended feature of GitHub that provides the CI-CD feature for application deployment. We have deployed the source code on EKS with the help of GitHub Actions.
Source: Read MoreÂ