Kubernetes GitOps example with IaC approach. This repository includes;
- IaC approach for EKS Kubernetes cluster creation with AWS best practices
- CI/CD with GitOps practices
- Secret management in K8s cluster with AWS Secret Manager
- Monitoring tools, such as Cloudwatch, Grafana, Prometheus
Terraform Repository For k8s-gitops Terraform Infrastructure.
The purpose of the project is to create a re-usable AWS infrastructure with an IaC approach using Terraform and Terragrunt. It is important to understand the fundamentals and milestones of Terraform and Terragrunt to understand this project.
- Install Terraform version
1.2.0
or newer and Terragrunt versionv0.38.0
or newer. - Configure your AWS credentials using one of the supported authentication mechanisms. The account you configured must have permission to assume a role on the account that will be used for Terraform operations.
- Fill in your AWS Account IDs in
<
environment>//account.hcl` which will be assumed for the terraform operations.
The code in this repo uses the following folder hierarchy:
root
└ _envcommon
└ environment
└ env.hcl
└ country/group
└ account.hcl
└ region
└ region.hcl
└ resource
Where:
- Root Level: At the top level are each of your Folders, such as
stage
,prod
,dev
, etc. There is also a_
envcommon` folder that defines resources that are available across all the environments for all continents. - Environment: Within each environment, you can deploy all the resources for that environment. There is a
env.hcl
file that defines environment-level variables. - Resource: Within each Resource, you can deploy the specific resource for that AWS Region.
cd
into the module's folder (e.g.cd platform/vpc
).- Run
terragrunt plan
to see the changes you're about to apply. - If the plan looks good, run
terragrunt apply
.
cd
into the region folder (e.g.cd platform
).- Run
terragrunt run-all plan
to see all the changes you're about to apply. - If the plan looks good, run
terragrunt run-all apply
.
cd
into the region folder (e.g.cd platform
).- Configure your OpsGenie-Promotheus integration API key:
export TF_VAR_prometheus_stack_alertmanager_opsgenie_api_key=(...)
. - Configure your OpsGenie-AWS CloudWatch integration API key:
export OPSGENIE_AWS_CLOUDWATCH_API_KEY=(...)
. - Run
terragrunt run-all plan
to see all the changes you're about to apply. - If the plan looks good, run
terragrunt run-all apply
.
cd
into the region folder (e.g.cd platform
).- Run
terragrunt run-all plan
to see all the changes you're about to apply. - If the plan looks good, run
terragrunt run-all apply
.