A complete Kubernetes monitoring solution deployed on AWS using Terraform. This project provides comprehensive observability with Prometheus, Grafana, and an EFK (Elasticsearch, Fluentd, Kibana) stack - all deployed using Terraform.
- ๐ Fully automated infrastructure provisioning with Terraform
- ๐ก๏ธ Secure RKE2 Kubernetes cluster on AWS EC2
- ๐ Prometheus & Grafana monitoring stack (via Terraform Helm provider)
- ๐ EFK logging stack (via Terraform Helm provider)
- ๐ TLS encryption with Let's Encrypt certificates
- ๐ Ingress Controller for external service access
- ๐งฉ Modular design with reusable Terraform modules
This solution implements a comprehensive Kubernetes monitoring and logging architecture with the following key components:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AWS Cloud โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ VPC / Networking โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ Master Node โ โ Worker Node(s) โ โ โ
โ โ โ โ โ โ โ โ
โ โ โ โโโโโโโโโโโโโโโ โ โ โโโโโโโโโโโโโโโ โ โ โ
โ โ โ โ Control โ โ โ โ Application โ โ โ โ
โ โ โ โ Plane โ โ โ โ Workloads โ โ โ โ
โ โ โ โโโโโโโโโโโโโโโ โ โ โโโโโโโโโโโโโโโ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ โ
โ โ RKE2 Kubernetes Cluster โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ Monitoring Stack โ โ Logging Stack โ โ โ
โ โ โ โ โ โ โ โ
โ โ โ โโโโโโโโโโโ โโโโโโโโโโโ โ โ โโโโโโโโโโโ โโโโโโโโโโโ โ โ โ
โ โ โ โPrometheusโ โ Grafana โ โ โ โElastic- โ โ Kibana โ โ โ โ
โ โ โ โOperator โ โ + Dash โ โ โ โsearch โ โ + Dash โ โ โ โ
โ โ โ โโโโโโโโโโโ โโโโโโโโโโโ โ โ โโโโโโโโโโโ โโโโโโโโโโโ โ โ โ
โ โ โ โ โ โ โ โ โ
โ โ โ โโโโโโโโโโโ โโโโโโโโโโโ โ โ โผ โ โ โ
โ โ โ โAlertMgr โ โ Pushgtw โ โ โ โโโโโโโโโโโ โ โ โ
โ โ โ โ โ โ โ โ โ โFluentd โ โ โ โ
โ โ โ โโโโโโโโโโโ โโโโโโโโโโโ โ โ โDaemonSetโ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ Ingress & Security โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โ โ โ โ โ โ โ
โ โ โ โโโโโโโโโโโ โโโโโโโโโโโ โ โ Terraform Infrastructure โ โ โ
โ โ โ โ Nginx โ โ Cert- โ โ โ Management โ โ โ
โ โ โ โ Ingress โ โ Manager โ โ โ โ โ โ
โ โ โ โโโโโโโโโโโ โโโโโโโโโโโ โ โ โข Infrastructure Modules โ โ โ
โ โ โ โ โ โข Helm Releases โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โข Configuration Management โ โ โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ โ
โ Monitoring Interface โ โ Logging Interface โ
โ โ โ โ
โ โข Metrics Visualization โ โ โข Log Aggregation โ
โ โข Alerting Dashboards โ โ โข Log Search & Analytics โ
โ โข Performance Monitoring โ โ โข Log Visualization โ
โ โข Resource Utilization โ โ โข Error Tracking โ
โ โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ โฒ
โ โ
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ DevOps Engineer โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
-
Infrastructure Layer
- AWS EC2 instances with appropriate security groups
- Networking with VPC, subnets, and security groups
- RKE2 Kubernetes cluster with high-availability configuration
-
Monitoring Stack
- Prometheus Operator for metrics collection
- Grafana for visualization with pre-configured dashboards
- Alertmanager for alert routing and notifications
- Node exporters for host-level metrics
-
Logging Stack
- Elasticsearch for log storage and indexing
- Fluentd for log collection (deployed as DaemonSet)
- Kibana for log visualization and analysis
-
Security & Access
- Nginx Ingress Controller for external access
- Cert-Manager with Let's Encrypt for TLS certificates
- RBAC for access control within Kubernetes
-
Infrastructure Management
- Terraform modules for all components
- Helm charts for application deployment
- Configuration management through Terraform
All components are deployed as Infrastructure as Code, enabling consistent, repeatable deployments and easy maintenance.
- Infrastructure: AWS EC2 instances with RKE2 Kubernetes cluster
- Monitoring: Prometheus, Grafana, AlertManager (via Terraform Helm provider)
- Logging: EFK (Elasticsearch, Fluentd, Kibana) (via Terraform Helm provider)
- Security: TLS certificates via cert-manager and Let's Encrypt
- Access: ingress-nginx for external service access
- terraform-rke2/: Terraform module for AWS RKE2 Kubernetes infrastructure
- kube-promstack/: Terraform module for Prometheus monitoring stack
- logging-stack/: Terraform module for EFK logging stack
- scripts/: Utility scripts for deployment and configuration
- AWS account with appropriate permissions
- Terraform (>= 0.14.0)
- kubectl (for cluster management)
# Clone the repository
git clone https://github.com/Teddydesta/terraform-rke2-monitoring-logging.git
cd terraform-rke2-monitoring-logging
# Deploy infrastructure and Kubernetes cluster
cd terraform-rke2
terraform init
terraform apply
# Deploy Prometheus monitoring stack
cd ../kube-promstack
terraform init
terraform apply -var="kube_config_path=../terraform-rke2/kubeconfig"
# Deploy EFK logging stack
cd ../logging-stack
terraform init
terraform apply -var="kube_config_path=../terraform-rke2/kubeconfig"
# Deploy additional components
cd ..
./scripts/deploy-extras.shAlternatively, use the provided Makefile for simpler deployment:
# Deploy everything
make deploy-all
# Or deploy individual components
make deploy-infra
make deploy-monitoring
make deploy-logging
make deploy-extrasFor more detailed information, refer to the module directories:
- terraform-rke2/: AWS infrastructure and RKE2 Kubernetes cluster configuration
- kube-promstack/: Prometheus monitoring stack setup
- logging-stack/: EFK logging stack configuration
Contributions are welcome! Please create a pull request with your changes.
This project is licensed under the MIT License - see the LICENSE file for details.
While the current implementation provides a comprehensive monitoring and logging solution, several DevOps-focused enhancements could further improve the system:
-
GitOps Workflow Implementation: Adopt Flux or ArgoCD to manage infrastructure and application deployments using Git as the single source of truth, enabling automated drift detection and reconciliation.
-
DevSecOps Pipeline Enhancement: Integrate security scanning (Trivy, Clair) into the CI/CD pipeline with automated vulnerability management and compliance checks. Implement OPA Gatekeeper for policy enforcement.
-
Infrastructure as Code Evolution: Migrate from Terraform HCL to Terraform CDK (or Pulumi) for advanced infrastructure modeling with proper abstractions, unit testing, and type safety.
-
Observability Platform Integration: Build a unified observability platform connecting Prometheus metrics, EFK logs, and distributed tracing (Jaeger/OpenTelemetry) with correlation capabilities.
-
Multi-Environment Promotion Pipeline: Implement a robust promotion pipeline (dev โ staging โ production) with automated canary deployments and progressive delivery using Flagger and service mesh.
-
Infrastructure Self-Service Portal: Create an internal developer platform using Backstage to enable self-service infrastructure provisioning with guardrails and governance.
-
Chaos Engineering Practice: Integrate Chaos Mesh or Litmus Chaos for automated chaos experiments to validate system resilience, with experiment results feeding into the CI/CD process.
-
FinOps Implementation: Deploy Kubecost or OpenCost with chargeback/showback capabilities, right-sizing recommendations, and automated scaling policies based on cost metrics.
-
Zero-Trust Security Model: Implement service mesh (Istio/Linkerd) with mTLS, network policies, and identity-based access controls across the entire infrastructure stack.
-
Compliance as Code: Integrate tools like Checkov or Terratest to automate compliance checks against CIS Benchmarks, SOC2, and other standards as part of the Infrastructure as Code workflow.
These improvements would transform the platform from a traditional monitoring solution into a comprehensive, enterprise-grade DevOps platform enabling sophisticated delivery workflows, enhanced security posture, and advanced operational capabilities.