This project demonstrates a complete setup for deploying microservices using Infrastructure as Code (IaC) with Terraform and Kubernetes. It includes a robust CI/CD pipeline using GitHub Actions, along with monitoring and alerting solutions.
- Features
- Prerequisites
- Project Structure
- Setup
- Infrastructure (Terraform)
- Kubernetes Deployment
- Monitoring and Logging
- Alerting
- Scripts
- CI/CD Pipeline
- Result
- Infrastructure as Code using Terraform
- Kubernetes deployment with NGINX Ingress and Cert-Manager
- Monitoring and logging with Prometheus and Grafana
- Alerting with Alertmanager
- Comprehensive CI/CD pipeline with GitHub Actions
- AWS Account
- GitHub Account
- Terraform (v1.3 or later)
- kubectl
- Helm
.
├── .github/workflows/
│ ├── terraform.yml
│ ├── kubernetes.yml
│ ├── monitoring.yml
│ └── alerting.yml
├── Alerting/
│ ├── alertmanager-configmap.yml
│ ├── alertmanager-dep.yml
│ └── alertmanager-svc.yml
├── Monitoring & Logging/
│ ├── [Prometheus & Grafana configuration files]
├── Kubernetes/
│ ├── certificate.yml
│ ├── clusterissuer.yml
│ ├── deploy.yml
│ └── ingress.yml
├── Scripts/
│ ├── run-terraform.sh
│ ├── apply-kubernetes.sh
│ ├── deploy-prometheus.sh
│ ├── deploy-grafana.sh
│ ├── alerting.sh
│ └── rollback.sh
└── Terraform/
├── main.tf
├── outputs.tf
├── provider.tf
├── terraform.tf
└── variables.tf
- Clone this repository: git clone https://github.com/Dev26x/sockshop.git cd sockshop Copy
- Set up AWS credentials:
- Create an IAM user with appropriate permissions
- Configure AWS CLI with the credentials
- Set up GitHub Secrets:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_CLUSTER_NAME
- Set up GitHub Variables:
- AWS_REGION (e.g., us-east-1)
The infrastructure is managed using Terraform. Key components include:
- VPC with public and private subnets
- EKS cluster with managed node groups
The project uses Kubernetes for orchestrating the microservices. Key components:
- NGINX Ingress Controller
- Cluster Issuer
- Cert-Manager for SSL/TLS
- Microservices deployment
- Ingress
By running the kubernetes script, these files are installed/applied to deploy microservices, issue certificate and secure the domain.
View all services and deployments using: kubectl get all -A
Remember to create A records in your domain dns pointing to the load balancer, and also create the same A record in your route 53 hosted zone.
Monitoring and logging is set up using Prometheus and Grafana.
I exposed prometheus and grafana to my dash board using port forwarding with these command:
kubectl port-forward service/prometheus 31090:9090 -n monitoring
kubectl port-forward service/grafana 31300:3000 -n monitoring
I also edited my prometheus errror rules to aid the alert manager with metrics for alerting.
By running the alerting.sh script, Alerting is configured with Alertmanager, which routes alerts to Slack.
By port-forwarding, alert manager can be viewed in the browser.
Purpose: Manages infrastructure provisioning and updates using Terraform.
- Terraform Initialization and Apply: The script initializes Terraform and applies the configuration to set up infrastructure resources, such as VPCs, EKS clusters, and other components.
- Outputs Variables: Outputs essential variables needed by subsequent workflows (e.g., Kubernetes cluster name, region).
Purpose: Deploys Kubernetes resources.
- Applies Kubernetes manifests using kubectl.
- Ensures that all necessary Kubernetes objects (e.g., Deployments, Services, Ingresses) are created or updated.
Purpose: Deploys Prometheus monitoring tool.
- Applies Prometheus manifests to the Kubernetes cluster.
- Configures Prometheus for monitoring.
Purpose: Deploys Grafana for visualization.
- Applies Grafana manifests to the Kubernetes cluster.
- Sets up Grafana dashboards and configurations.
Purpose: Configures and deploys alerting setups.
- Applies alerting configurations, such as Alertmanager and related alerting rules.
- Sets up the alerting pipeline to integrate with Prometheus.
The CI/CD pipeline is implemented using GitHub Actions and consists of four workflows:
-
Terraform
-
Kubernetes Deployment
-
Monitoring and Logging
-
Alerting
The application is accessible on my domain (www.dev26x.com.ng) over HTTPS and secured using Let’s Encrypt for certificates.

























