# Serverless Amazon EKS Cluster This example shows how to provision an Amazon EKS Cluster (serverless data plane) using Fargate Profiles. This example solution provides: - AWS EKS Cluster (control plane) - AWS EKS Fargate Profiles for the `kube-system` namespace which is used by the `coredns`, `vpc-cni`, and `kube-proxy` addons, as well as profile that will match on `app-*` namespaces using a wildcard pattern. - AWS EKS managed addons `coredns`, `vpc-cni` and `kube-proxy` - AWS Load Balancer Controller add-on deployed through a Helm chart. The default AWS Load Balancer Controller add-on configuration is overridden so that it can be deployed on Fargate compute. - A sample-app is provided (in-line) to demonstrate how to configure the Ingress so that application can be accessed over the internet. ## Prerequisites: Ensure that you have the following tools installed locally: 1. [aws cli](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) 2. [kubectl](https://Kubernetes.io/docs/tasks/tools/) 3. [terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli) ## Deploy To provision this example: ```sh terraform init terraform apply ``` Enter `yes` at command prompt to apply ## Validate The following command will update the `kubeconfig` on your local machine and allow you to interact with your EKS Cluster using `kubectl` to validate the CoreDNS deployment for Fargate. 1. Check the Terraform provided Output, to update your `kubeconfig` ```hcl Apply complete! Resources: 63 added, 0 changed, 0 destroyed. Outputs: configure_kubectl = "aws eks --region us-west-2 update-kubeconfig --name fargate-serverless" ``` 2. Run `update-kubeconfig` command, using the Terraform provided Output, replace with your `$AWS_REGION` and your `$CLUSTER_NAME` variables. ```sh aws eks --region <$AWS_REGION> update-kubeconfig --name <$CLUSTER_NAME> ``` 3. Test by listing Nodes in in the Cluster, you should see Fargate instances as your Cluster Nodes. ```sh kubectl get nodes NAME STATUS ROLES AGE VERSION fargate-ip-10-0-17-17.us-west-2.compute.internal Ready 25m v1.26.3-eks-f4dc2c0 fargate-ip-10-0-20-244.us-west-2.compute.internal Ready 71s v1.26.3-eks-f4dc2c0 fargate-ip-10-0-41-143.us-west-2.compute.internal Ready 25m v1.26.3-eks-f4dc2c0 fargate-ip-10-0-44-95.us-west-2.compute.internal Ready 25m v1.26.3-eks-f4dc2c0 fargate-ip-10-0-45-153.us-west-2.compute.internal Ready 77s v1.26.3-eks-f4dc2c0 fargate-ip-10-0-47-31.us-west-2.compute.internal Ready 75s v1.26.3-eks-f4dc2c0 fargate-ip-10-0-6-175.us-west-2.compute.internal Ready 25m v1.26.3-eks-f4dc2c0 ``` 4. Test by listing all the Pods running currently. All the Pods should reach a status of `Running` after approximately 60 seconds: ```sh kubectl get pods -A NAMESPACE NAME READY STATUS RESTARTS AGE app-2048 app-2048-65bd744dfb-7g9rx 1/1 Running 0 2m34s app-2048 app-2048-65bd744dfb-nxcbm 1/1 Running 0 2m34s app-2048 app-2048-65bd744dfb-z4b6z 1/1 Running 0 2m34s kube-system aws-load-balancer-controller-6cbdb58654-fvskt 1/1 Running 0 26m kube-system aws-load-balancer-controller-6cbdb58654-sc7dk 1/1 Running 0 26m kube-system coredns-7b7bddbc85-jmbv6 1/1 Running 0 26m kube-system coredns-7b7bddbc85-rgmzq 1/1 Running 0 26m ``` 5. Check if the `aws-logging` configMap for Fargate Fluentbit was created. ```sh kubectl -n aws-observability get configmap aws-logging -o yaml apiVersion: v1 data: filters.conf: | [FILTER] Name parser Match * Key_Name log Parser regex Preserve_Key True Reserve_Data True flb_log_cw: "true" output.conf: | [OUTPUT] Name cloudwatch_logs Match * region us-west-2 log_group_name /fargate-serverless/fargate-fluentbit-logs20230509014113352200000006 log_stream_prefix fargate-logs- auto_create_group true parsers.conf: | [PARSER] Name regex Format regex Regex ^(?