Bootstrap AWS EKS with Autoscaler and Gitops
Published: 2023-12-05 00:10:57

## Overview

* Create Initial AWS Resources
* Update locals.tf and provider.tf with Initial AWS Resource Details
* Run Terraform to create Terraformed AWS Resources
* Run ./script/configure.sh to update FluxCD Manafests with Terraformed AWS Resource Details
* Create Github Resources and set credentials Env Variables
* Run Flux Bootstrap to deploy Initial GitOps Resources, GitOps controlled K8s Addons & Configs, GitOps controlled K8s Apps

### Inital AWS Resources

* [AWS Account](https://docs.aws.amazon.com/accounts/latest/reference/accounts-welcome.html) - A basic container for AWS resources and security boundary.
* [Identity Center User](https://aws.amazon.com/iam/identity-center) - Short-lived authentication.  No distributing access keys and associated risk of exposed secrets.  Forced 2FA for CLI Access.
* [S3 Bucket](https://aws.amazon.com/s3/) for [Terraform State](https://developer.hashicorp.com/terraform/language/state) - Terraform must store state about managed infrastructure and configuration. This state is used by Terraform to map real world resources to your configuration, and keep track of metadata
* [Dynamo DB](https://aws.amazon.com/dynamodb/) for [Terraform State Locking](https://developer.hashicorp.com/terraform/language/state/locking) - Ensures that only one operation (like apply or plan) that could write or change the state is performed at a time.  Price likely not a concern given DynamoDB's Utility Pricing model and the low volume of transactions.
* [Route53 Zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-working-with.html) - Controls how to Route traffic for a specific domain, and subdomains.

### Github Resources

* [Repository](https://fluxcd.io/flux/guides/repository-structure/) - The Source of Truth for your Infrastructure.  FluxCD will monitor this repo (and the repos it references) for changes and applies them to your cluster.
* [Flux User for Github Organization](https://fluxcd.io/flux/installation/bootstrap/github/#github-organization) - When performing GitOps using a Organization Owned Repo, Flux recommends you create a dedicated user.
* [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) - Flux requires Github Authentication Secrets since it acts on your repo during the bootstrap process.

### Terraformed AWS Resources

* ACM - [Amazon Certficate Manager](https://aws.amazon.com/certificate-manager/) - Provision and manage SSL/TLS certificates with AWS services and connected resources
* VPC - [Amazon Virtual Private Cloud](https://aws.amazon.com/vpc/) - Define and launch AWS resources in a logically isolated virtual network
* EKS - [Amazon Elastic Kubernetes Service](https://aws.amazon.com/eks/?nc2=type_a) - The most trusted way to start, run, and scale Kubernetes
* ECR - [Amazon Elastic Container Registry](https://aws.amazon.com/ecr/) - Easily store, share, and deploy your container software anywhere
* EKS Roles - [IAM Roles for Service Accounts](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html) - Allow K8s pods to assume specific AWS IAM roles, enabling fine-grained permission control for applications, such as an K8s Autoscaler, without embedding AWS credentials within them.

### Initial GitOps Resources

* [GitRepository](https://fluxcd.io/flux/components/source/gitrepositories/) (A Continious Delivery Source)
* [Kustomization](https://fluxcd.io/flux/components/kustomize/) (A Continious Delivery Pipeline)

### GitOps Controlled K8s Addons & Configs
 
 * [Load Balance Controller](https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.6/)
 * [Cluster Autoscaler](https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler) - Cluster Autoscaler - a component that automatically adjusts the size of a Kubernetes Cluster so that all pods have a place to run and there are no unneeded nodes.  `Requires Kubernetes v1.3.0 or greater`
 * [External DNS](https://kubernetes-sigs.github.io/external-dns/v0.14.0/) - External DNS - a Kubernetes addon that configures public DNS servers with information about exposed Kubernetes Services to make them discoverable. 
 * [Metrics Server](https://kubernetes-sigs.github.io/metrics-server/) - Metrics Server is a scalable, efficient source of container resource metrics for Kubernetes built-in autoscaling pipelines.

### GitOps Controlled K8s Apps

* [Weave-Gitops](https://docs.gitops.weave.works/) - GitOps UI for FluxCD

### Other Resources

* https://github.com/aws-samples/flux-eks-gitops-config