-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Seperate karpenter config to a submodule (#346)
* Seperate karpenter config to a submodule It seemed a bit weird that we did a lot of work to remove all of the non-core functions from the module, just to add the support for karpenter as a core part of the module. Moving support for Karpenter to a submodule doesn't make configuring a cluster much more dificult, but does reduce the complexity of the core module, and hopefully should make ongoing maintince a little simpler. Especially if we decided to use some other node provisioning tool in the future. * fmt
- Loading branch information
Showing
13 changed files
with
130 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Karpenter | ||
|
||
This module configures the resources required to run the | ||
karpenter node-provisioning tool in an eks cluster. | ||
|
||
* Fargate Profile - to run karpenter | ||
* IAM roles for the fargate controller and nodes to be provisioned by karpenter | ||
* SQS queue to provide events (spot interruption etc) to karpenter | ||
|
||
It does not install karpenter itself to the cluster - and we recomend | ||
that you use helm as per the [karpenter documentation](https://karpenter.sh/docs/getting-started/getting-started-with-karpenter/#4-install-karpenter) | ||
|
||
It is provided as a submodule so the core module is less opinionated. | ||
|
||
However we test the core module and the karpenter module | ||
in our test suite to ensure that the different components we use in our | ||
clusters at cookpad intergrate correctly. | ||
|
||
|
||
## Example | ||
|
||
You should pass cluster and oidc config from the cluster to the karpenter module. | ||
|
||
You will also need to add the IAM role of nodes created by karpenter to the aws_auth_role_map | ||
so they can connect to the cluster. | ||
|
||
```hcl | ||
module "cluster" { | ||
source = "cookpad/eks/aws" | ||
aws_auth_role_map = [ | ||
{ | ||
username = "system:node:{{EC2PrivateDNSName}}" | ||
rolearn = module.karpenter.node_role_arn | ||
groups = [ | ||
"system:bootstrappers", | ||
"system:nodes", | ||
] | ||
}, | ||
] | ||
} | ||
module "karpenter" { | ||
source = "cookpad/eks/aws//modules/karpenter" | ||
cluster_config = module.cluster.config | ||
oidc_config = module.cluster.oidc_config | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
data "aws_partition" "current" {} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
resource "aws_eks_fargate_profile" "critical_pods" { | ||
cluster_name = var.cluster_config.name | ||
fargate_profile_name = "${var.cluster_config.name}-karpenter" | ||
pod_execution_role_arn = var.cluster_config.fargate_execution_role_arn | ||
subnet_ids = values(var.cluster_config.private_subnet_ids) | ||
|
||
selector { | ||
namespace = "karpenter" | ||
labels = {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "node_role_arn" { | ||
value = aws_iam_role.karpenter_node.arn | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
variable "cluster_config" { | ||
description = "EKS cluster config object" | ||
type = object({ | ||
name = string | ||
arn = string | ||
private_subnet_ids = map(string) | ||
iam_role_name_prefix = string | ||
fargate_execution_role_arn = string | ||
}) | ||
} | ||
|
||
variable "oidc_config" { | ||
description = "OIDC config object" | ||
type = object({ | ||
url = string | ||
arn = string | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 4.47.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters