Skip to content

Commit 077db4b

Browse files
author
manishsf444
committed
Merge pull request #114 from sourcefuse/refactor/eks
EKS Refactor
1 parent f4444d5 commit 077db4b

File tree

1 file changed

+175
-7
lines changed
  • docs/arc-iac-docs/modules/terraform-aws-ref-arch-eks/docs/module-usage-guide

1 file changed

+175
-7
lines changed

docs/arc-iac-docs/modules/terraform-aws-ref-arch-eks/docs/module-usage-guide/README.md

Lines changed: 175 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Before using this module, ensure you have the following:
1818

1919
- AWS credentials configured.
2020
- Terraform installed.
21-
- A working knowledge of AWS VPC, EKS, Kubernetes, Helm and Terraform concepts.
21+
- A working knowledge of AWS VPC, EKS, Kubernetes, Helm, Karpenter and Terraform concepts.
2222

2323
## Getting Started
2424

@@ -29,7 +29,7 @@ To use the module in your Terraform configuration, include the following source
2929
```hcl
3030
module "arc-eks" {
3131
source = "sourcefuse/arc-eks/aws"
32-
version = "5.0.0"
32+
version = "5.0.16"
3333
# insert the 8 required variables here
3434
}
3535
```
@@ -41,7 +41,7 @@ Refer to the [Terraform Registry](https://registry.terraform.io/modules/sourcefu
4141
Integrate the module with your existing Terraform mono repo configuration, follow the steps below:
4242

4343
1. Create a new folder in `terraform/` named `eks`.
44-
2. Create the required files, see the [examples](https://github.com/sourcefuse/terraform-aws-arc-eks/tree/main/example) to base off of.
44+
2. Create the required files, see the [examples](https://github.com/sourcefuse/terraform-aws-arc-eks/tree/main/examples) to base off of.
4545
3. Configure with your backend
4646
- Create the environment backend configuration file: `config.<environment>.hcl`
4747
- **region**: Where the backend resides
@@ -55,7 +55,7 @@ Integrate the module with your existing Terraform mono repo configuration, follo
5555
Ensure that the AWS credentials used to execute Terraform have the necessary permissions to create, list and modify:
5656

5757
- EKS cluster
58-
- EKS node groups, EC2 AMIs, Launch templates
58+
- EKS node groups, EC2 AMIs
5959
- EKS Fargate profile
6060
- Security Groups and Security Group rules
6161
- Cloudwatch Log groups
@@ -76,15 +76,183 @@ For a list of outputs, see the README [Outputs](https://github.com/sourcefuse/te
7676

7777
### Basic Usage
7878

79-
For basic usage, see the [example](https://github.com/sourcefuse/terraform-aws-arc-eks/tree/main/example) folder.
79+
For basic usage, see the [examples/simple](https://github.com/sourcefuse/terraform-aws-arc-eks/tree/main/examples/simple) folder.
8080

8181
This example will create:
8282

83-
- An EKS cluster with a single EC2 node group.
83+
- An EKS cluster.
84+
85+
### Additional Usage Patterns
86+
87+
Below are advanced usage examples enabled by this module to support a range of EKS deployment strategies:
88+
89+
---
90+
91+
#### 1. **EKS with Managed Node Groups**
92+
93+
For EKS Cluster with node-group creation, see the [examples/node-group](https://github.com/sourcefuse/terraform-aws-arc-eks/tree/main/examples/node-group) folder.
94+
95+
Use `node_group_config` to provision one or more managed node groups with specific instance types, scaling configuration, and networking.
96+
97+
**Key Capabilities:**
98+
- Support for ON_DEMAND and SPOT instances.
99+
- Control over desired, min, and max node counts.
100+
- Custom disk size, AMI type, and instance types.
101+
- Define multiple node groups for various workloads.
102+
103+
**Example Use Case:**
104+
You need a general-purpose node group for application workloads and a spot node group for cost-optimized batch jobs.
105+
106+
**How to Use:**
107+
```hcl
108+
node_group_config = {
109+
enable = true
110+
config = {
111+
general-ng = {
112+
node_group_name = "general-nodegroup"
113+
subnet_ids = data.aws_subnets.private.ids
114+
scaling_config = {
115+
desired_size = 2
116+
max_size = 3
117+
min_size = 1
118+
}
119+
instance_types = ["t3.medium"]
120+
capacity_type = "ON_DEMAND"
121+
disk_size = 20
122+
ami_type = "AL2_x86_64"
123+
}
124+
}
125+
}
126+
```
127+
128+
---
129+
130+
#### 2. **EKS with Fargate Profile**
131+
132+
For EKS Cluster with fargate-profile creation, see the [examples/fargate-profile](https://github.com/sourcefuse/terraform-aws-arc-eks/tree/main/examples/fargate-profile) folder.
133+
134+
Enable `fargate_profile_config` to run specific workloads on AWS Fargate — a serverless compute engine — ideal for lightweight, isolated, or on-demand applications without managing underlying infrastructure.
135+
136+
**Key Capabilities:**
137+
- Eliminates the need to manage EC2 nodes for specific workloads.
138+
- Ideal for low-resource, burstable or security-isolated workloads.
139+
- Assign specific namespaces to Fargate using selectors.
140+
141+
**Example Use Case:**
142+
An `AWS EKS Fargate profile` allows an administrator to declare which pods run on Fargate and specify which pods run on which Fargate profile through selectors.
143+
144+
**How to Use:**
145+
```hcl
146+
fargate_profile_config = {
147+
enable = true
148+
fargate_profile_name = "example"
149+
subnet_ids = data.aws_subnets.private.ids
150+
selectors = [
151+
{
152+
namespace = "example"
153+
}
154+
]
155+
}
156+
```
157+
158+
---
159+
160+
#### 3. **Auto Mode Support**
161+
162+
For EKS Cluster with auto-mode creation, see the [examples/auto-mode](https://github.com/sourcefuse/terraform-aws-arc-eks/tree/main/examples/auto-mode) folder.
163+
164+
This module supports an **Auto Mode** configuration, `EKS Auto Mode` extends AWS management of Kubernetes clusters beyond the cluster itself, to allow AWS to also set up and manage the infrastructure that enables the smooth operation of your workloads.
165+
166+
**Key Capabilities:**
167+
- Simplified Cluster Operations: Automatically provisions production-ready EKS clusters with minimal manual configuration or deep Kubernetes expertise.
168+
- Dynamic Scaling: Continuously adjusts cluster capacity by adding/removing nodes based on application demand, ensuring high availability without manual planning.
169+
- Cost Efficiency: Optimizes compute usage by consolidating workloads and terminating idle instances to reduce operational costs.
170+
- Enhanced Security: Uses immutable, hardened AMIs with SELinux, read-only file systems, and automatic node recycling every 21 days to maintain a strong security posture.
171+
- Automated Maintenance: Keeps your cluster components up to date with automated patching that respects disruption budgets.
172+
- Built-In Add-ons: Includes essential networking, storage, and observability components (e.g., Pod networking, DNS, CSI drivers) without requiring manual add-on setup.
173+
- Custom Node Configuration: Supports creation of custom NodePools and NodeClasses to fine-tune compute, storage, and networking based on workload needs.
174+
175+
**Example Use Case:**
176+
You want to deploy workloads that require automatic scaling based on resource demands.
177+
178+
**How to Use:**
179+
```hcl
180+
module "eks_cluster" {
181+
source = "../../"
182+
namespace = "arc"
183+
environment = "poc"
184+
kubernetes_version = "1.31"
185+
name = "${var.namespace}-${var.environment}-cluster"
186+
vpc_config = local.vpc_config
187+
auto_mode_config = local.auto_mode_config
188+
bootstrap_self_managed_addons_enabled = false # Make sure this is false for auto-mode creation
189+
access_config = local.access_config
190+
enable_oidc_provider = false
191+
envelope_encryption = local.envelope_encryption
192+
kubernetes_network_config = local.kubernetes_network_config
193+
}
194+
```
195+
196+
---
197+
198+
#### 4. **Karpenter Integration**
199+
200+
For EKS Cluster with karpenter creation, see the [examples/karpenter](https://github.com/sourcefuse/terraform-aws-arc-eks/tree/main/examples/karpenter) folder.
201+
202+
Enable `karpenter_config` to provision and manage dynamic compute capacity for Kubernetes workloads using [Karpenter](https://karpenter.sh/).
203+
204+
**Key Capabilities:**
205+
- Auto-provision capacity based on pod requirements.
206+
- Faster scaling and cost-optimization compared to static node groups.
207+
- Fully automated with Helm-based deployment.
208+
209+
**Example Use Case:**
210+
You need highly dynamic compute provisioning with support for heterogeneous workloads and instance types, with minimal manual intervention.
211+
212+
**How to Use:**
213+
```hcl
214+
karpenter_config = {
215+
enable = true
216+
name = "karpenter"
217+
namespace = "karpenter"
218+
version = "0.36.0"
219+
helm_release_values = [file("${path.module}/karpenter-helm-values.yaml")]
220+
helm_release_set_values = [
221+
{
222+
name = "dnsPolicy"
223+
value = "Default"
224+
}
225+
]
226+
}
227+
```
228+
229+
**Required Setup:**
230+
- Ensure proper tags are applied to subnets and security groups:
231+
```hcl
232+
resource "aws_ec2_tag" "karpenter_discovery" {
233+
resource_id = <subnet_or_sg_id>
234+
key = "karpenter.sh/discovery"
235+
value = module.eks_cluster.name
236+
}
237+
```
238+
239+
**NodeClass and NodePool Example:**
240+
```hcl
241+
resource "kubectl_manifest" "karpenter_nodeclass" {
242+
yaml_body = file("${path.module}/karpenter-nodeclass.yaml")
243+
}
244+
```
245+
246+
---
84247

85248
### Tips and Recommendations
86249

87-
- This module only creates a single node group with up to 20 distinct instance types. If additional node groups groups are needed, the same may be provisioned downstream.
250+
- Use `node_group_config` for granular node group management
251+
- Use `karpenter_config` for dynamic compute provisioning
252+
- Leverage `fargate_profile_config` for low-priority or bursty workloads
253+
- Consider EKS Auto Mode for minimal operational overhead
254+
- Use custom `access_config` to centralize EKS access management
255+
88256

89257
## Troubleshooting
90258

0 commit comments

Comments
 (0)