This README provides instructions on how to deploy the Proshop App using the Terraform EKS Deployment Workflow. It is intended to guide users through the process of deploying the application to AWS using Terraform, ECR, EKS, Kubernetes, and Helm.
- Overview
- Prerequisites
- Create a Kubernetes Cluster on AWS
- Workflow Overview
- Steps to Deploy
- Usage
- Troubleshooting
- Links to Documentation
The Proshop App CI/CD pipeline uses Terraform to manage infrastructure on AWS and Helm to deploy applications to a Kubernetes cluster. This guide explains how to deploy the application using the workflow provided.
- Terraform: Infrastructure as Code (IaC) tool for provisioning AWS resources.
- GitHub Actions: Used to automate the CI/CD process, including deployment to AWS EKS.
- Amazon ECR: Stores Docker images for the backend and frontend applications.
- Amazon EKS: Kubernetes service that hosts the applications.
- Helm: Manages Kubernetes applications for both backend and frontend services.
Before deploying, ensure you have the following:
- AWS Account with necessary permissions to manage ECR, EKS, and IAM roles.
- GitHub Repository with the following secrets set:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
IAM_ROLE
: The IAM role ARN for GitHub Actions.
- Terraform and Helm installed locally if you plan to run commands manually.
You must create a Kubernetes cluster using Amazon EKS to deploy the Proshop App. Here are the steps to create an EKS cluster:
-
Create an EKS Cluster using Terraform: Use the Terraform configuration provided in this repository to create an EKS cluster. This configuration automates the process of provisioning all necessary AWS resources for the EKS cluster.
Run the following Terraform commands:
terraform init terraform apply -var-file=project-x.tfvars
This will provision the EKS cluster, configure the necessary networking components (VPC, subnets), and create a Kubernetes control plane.
-
Configure kubectl for AWS EKS: After the EKS cluster is created, update your local Kubernetes configuration to interact with the EKS cluster:
aws eks update-kubeconfig --name <cluster-name> --region <region>
This step will configure
kubectl
to communicate with your new Kubernetes cluster. -
Verify Kubernetes Cluster: Run the following command to ensure the Kubernetes cluster is correctly set up:
kubectl get nodes
You should see a list of nodes that are part of your EKS cluster.
Once the Kubernetes cluster is up and running, you can proceed with deploying the Proshop App using the provided CI/CD pipeline.
This workflow is triggered on push events to the dev
branch and pull requests to the main
branch. It supports manual dispatch (workflow_dispatch
) and automates the following tasks:
- Initialize Terraform and apply infrastructure changes.
- Build and push Docker images for the backend and frontend to Amazon ECR.
- Deploy the backend and frontend to Amazon EKS using Helm.
- Configure Kubernetes and AWS resources.
The workflow triggers on:
- Pushes to the
dev
branch. - Pull requests to the
main
branch. - Manual dispatch.
Ensure the following secrets are configured in your GitHub repository:
AWS_ACCESS_KEY_ID
: Your AWS Access Key.AWS_SECRET_ACCESS_KEY
: Your AWS Secret Access Key.IAM_ROLE
: The ARN of the IAM role with permissions to manage EKS and ECR.
This workflow initializes and validates the Terraform configuration, applies infrastructure changes, and manages the AWS resources.
The Docker images for the backend and frontend are built and pushed to Amazon ECR if the branch is not main
.
The workflow logs into the EKS cluster to update the kubeconfig and install necessary services, such as the NGINX Ingress Controller and the Secrets Store CSI Driver.
The backend and frontend applications are deployed to the EKS cluster using Helm with the respective dev-values.yaml
files. Helm charts handle application configuration and deployment.
- Push Code: Push your code changes to the
dev
branch or open a pull request to themain
branch. - Trigger Workflow: The workflow will automatically execute, deploying your infrastructure and application.
- Monitor Deployment: You can monitor the deployment in the GitHub Actions tab for the repository.
- Verify Deployment: Ensure your backend and frontend services are running on your EKS cluster by checking Kubernetes resources.
- AWS Authentication Issues: Ensure that your GitHub secrets are correctly configured and that your IAM role has sufficient permissions.
- Kubernetes Deployment Failures: Check the Helm release logs and Kubernetes events for errors.
- Docker Build Failures: Review the Docker build logs in the Actions tab.
- Terraform Documentation
- AWS ECR Documentation
- Amazon EKS Documentation
- Helm Documentation
- GitHub Actions Documentation
By following these instructions, you can create a Kubernetes cluster on AWS and deploy the Proshop App, ensuring efficient infrastructure management and continuous delivery using modern DevOps tools and practices.