Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shazchaudhry/terraform-eks
Create Amazon EKS cluster with Terraform where EKS private API server endpoint is enabled.
https://github.com/shazchaudhry/terraform-eks
eks terraform
Last synced: about 2 months ago
JSON representation
Create Amazon EKS cluster with Terraform where EKS private API server endpoint is enabled.
- Host: GitHub
- URL: https://github.com/shazchaudhry/terraform-eks
- Owner: shazChaudhry
- Created: 2019-05-28T19:45:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-09-19T11:09:09.000Z (over 1 year ago)
- Last Synced: 2023-09-19T13:34:04.254Z (over 1 year ago)
- Topics: eks, terraform
- Language: HCL
- Homepage:
- Size: 161 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Terraform](https://github.com/shazChaudhry/terraform-eks/actions/workflows/terraform.yml/badge.svg)](https://github.com/shazChaudhry/terraform-eks/actions/workflows/terraform.yml)
This repo is inspired by [Amazon EKS Blueprints for Terraform](https://aws-ia.github.io/terraform-aws-eks-blueprints/).
This project includes the following components:
- EKS version = `1.24` (this value is defined in `terraform.tfvars`)
- Both public and private access endpoints enabled
- Terraform state file saved in a S3 bucket
- Required Terraform version is `>= 1.3.7`
- The following [Amazon EKS add-ons](https://docs.aws.amazon.com/eks/latest/userguide/eks-add-ons.html) are enabled:
- enable_amazon_eks_coredns
- enable_amazon_eks_kube_proxy
- enable_amazon_eks_vpc_cni
- enable_amazon_eks_aws_ebs_csi_driver
- The following K8s Add-ons
- [enable_metrics_server](https://github.com/aws-ia/terraform-aws-eks-blueprints/tree/main/modules/kubernetes-addons/metrics-server)
- [enable_karpenter](https://karpenter.sh)
- [enable_aws_cloudwatch_metrics](https://github.com/aws-ia/terraform-aws-eks-blueprints/tree/main/modules/kubernetes-addons/aws-cloudwatch-metrics)
- [enable_aws_efs_csi_driver](https://github.com/aws-ia/terraform-aws-eks-blueprints/tree/main/modules/kubernetes-addons/aws-efs-csi-driver)
- [enable_aws_node_termination_handler](https://github.com/aws/aws-node-termination-handler)
- [enable_tetrate_istio](https://istio.tetratelabs.io)
- [enable_calico](https://projectcalico.docs.tigera.io/getting-started/kubernetes/quickstart)
- [enable_kubecost](https://docs.aws.amazon.com/eks/latest/userguide/cost-monitoring.html)
- enable_kubernetes_dashboard _(in kube-system namespace)_
- Still need to figure out how to use this kubernetes web UI [Dashboard](https://docs.aws.amazon.com/eks/latest/userguide/dashboard-tutorial.html)## Prerequisites
- An [AWS account](https://portal.aws.amazon.com/billing/signup/iam?nc2=h_ct&redirect_url=https%3A%2F%2Faws.amazon.com%2Fregistration-confirmation&src=default#/support)
- A configured AWS CLI
- AWS IAM Authenticator
- [kubectl](https://learn.hashicorp.com/tutorials/terraform/eks#kubectl)
- Ensure that AWS credentials are available at: "~/.aws/credentials" on the host dev machine
```terraform
[default]
aws_access_key_id =
aws_secret_access_key =
region =
```
- Ensure that an S3 bucket as a backend type is created in[versions.tf](versions.tf). See the docs [here](https://www.terraform.io/docs/backends/types/s3.html)
```terraform
terraform {
backend "s3" {
key = "eks/terraform.tfstate"
region = ""
encrypt = true
# Lock Terraform State with S3 bucket in DynamoDB - https://www.terraform.io/docs/language/settings/backends/s3.html#dynamodb-state-locking
dynamodb_table = "statefile"
}
}
```
- Ensure a globally unique S3 bucket name already exists that is specific to your environment in [environments/dev/backend.tf](environments/dev/backend.tf)## Setup cluster
Run the following command to set up the cluster
```terraform
export environment=dev
# Initialize Terraform workspace
terraform init -backend-config=environments/${environment}/backend.tf
# Review the planned actions before continuing
terraform apply --var-file=environments/${environment}/${environment}.tfvars
# Configure kubectl
aws eks --region $(terraform output -raw region) update-kubeconfig --name $(terraform output -raw cluster_name)
```## Destroy cluster
```terraform
terraform apply -destroy -var-file=environments/${environment}/${environment}.tfvars
```## Fix this error
Doc for enabling this add-on is on this page:https://aws-ia.github.io/terraform-aws-eks-blueprints/v4.21.0/add-ons/kube-state-metrics/.
It appears that this particular add-on is currently disabled and the blueprint docs have yet to be (annoyingly) corrected. Here is the closed issue: https://github.com/aws-ia/terraform-aws-eks-blueprints/issues/464#issuecomment-1107485356```shell
Error: Unsupported argument
on kubernetes_addons.tf line 23, in module "eks_blueprints_kubernetes_addons":
23: enable_kube_state_metrics = true
An argument named "enable_kube_state_metrics" is not expected here.
```## References
- Amazon EKS - [User Guide](https://docs.aws.amazon.com/eks/latest/userguide/what-is-eks.html)
- EKS Best Practices - [Guides](https://aws.github.io/aws-eks-best-practices/)
- Bootstrapping clusters with EKS Blueprints [blog](https://aws.amazon.com/blogs/containers/bootstrapping-clusters-with-eks-blueprints/)
- [AWS EKS Blueprints for Terraform - docs](https://aws-ia.github.io/terraform-aws-eks-blueprints/)
- [AWS EKS Blueprints for Terraform - GitHub repo](https://github.com/aws-ia/terraform-aws-eks-blueprints)`
- [AWS EKS Blueprints for Terraform - YouTube](https://www.youtube.com/watch?v=TXa-y-Uwh2w)