This repository contains infrastructure code used to bootstrap an Amazon EKS environment with the most common components and integrations enabled using Terraform.
- aws-cli
- terraform aws/vpc
- terraform aws/eks
- terraform eks-blueprints-addons
- terraform aws-observability-accelerator
- Clone this repository:
git clone https://github.com/davivcgarcia/aws-eks-sandbox.git
cd aws-eks-sandbox/
- Provision infrastructure with Terraform:
cd tf/
terraform init
terraform apply
- Update Kubeconfig using the new cluster parameters:
EKS_CLUSTER_NAME=$(terraform output -raw EKSClusterName)
EKS_CLUSTER_REGION=$(terraform output -raw EKSClusterRegion)
aws eks update-kubeconfig --name $EKS_CLUSTER_NAME --region $EKS_CLUSTER_REGION
- Delete all Karpenter resources to remove EC2 Fleet instances:
kubectl delete NodePools,EC2NodeClass --all
- Delete all network resources to LB Controller to remove ELBs:
kubectl get services --all-namespaces -o json | jq -r '.items[] | select(.spec.type == "LoadBalancer") | .metadata.name + " " + .metadata.namespace' | while read name namespace; do kubectl delete service $name -n $namespace; done
kubectl get ingress --all-namespaces -o json | jq -r '.items[] | select(.spec.ingressClassName == "alb") | .metadata.namespace + " " + .metadata.name' | while read name namespace; do kubectl delete ingress $name -n $namespace; done
- Delete all storage resources to LB Controller to remove EBS/EFS:
kubectl delete pvc --all-namespaces --all
kubectl delete pv --all
- Destroy AWS resources created by Terraform:
terraform destroy