Skip to content

Commit

Permalink
Merge pull request #7 from truefoundry/karpenter-fargate
Browse files Browse the repository at this point in the history
Karpenter fargate
  • Loading branch information
dunefro authored Jul 2, 2024
2 parents e70bf3c + 65227ec commit 84248a4
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ No resources.
| <a name="input_eks_managed_node_groups"></a> [eks\_managed\_node\_groups](#input\_eks\_managed\_node\_groups) | Map of EKS managed node group definitions to create | `any` | `{}` | no |
| <a name="input_enable_irsa"></a> [enable\_irsa](#input\_enable\_irsa) | Determines whether to create an OpenID Connect Provider for EKS to enable IRSA | `bool` | `true` | no |
| <a name="input_iam_role_additional_policies"></a> [iam\_role\_additional\_policies](#input\_iam\_role\_additional\_policies) | Additional policies to be added to the IAM role | `map(string)` | `{}` | no |
| <a name="input_karpenter_fargate_profile_attach_cni_policy"></a> [karpenter\_fargate\_profile\_attach\_cni\_policy](#input\_karpenter\_fargate\_profile\_attach\_cni\_policy) | Attach CNI policy to IAM role for Karpenter Fargate profile | `bool` | `true` | no |
| <a name="input_karpenter_fargate_profile_create_iam_role"></a> [karpenter\_fargate\_profile\_create\_iam\_role](#input\_karpenter\_fargate\_profile\_create\_iam\_role) | Create IAM role for Karpenter Fargate profile | `bool` | `true` | no |
| <a name="input_karpenter_fargate_profile_enabled"></a> [karpenter\_fargate\_profile\_enabled](#input\_karpenter\_fargate\_profile\_enabled) | Enable Karpenter Fargate profile | `bool` | `false` | no |
| <a name="input_karpenter_fargate_profile_namespace"></a> [karpenter\_fargate\_profile\_namespace](#input\_karpenter\_fargate\_profile\_namespace) | value of the namespace where Karpenter is installed | `string` | `"karpenter"` | no |
| <a name="input_node_security_group_additional_rules"></a> [node\_security\_group\_additional\_rules](#input\_node\_security\_group\_additional\_rules) | List of additional security group rules to add to the node security group created. Set `source_cluster_security_group = true` inside rules to set the `cluster_security_group` as source | `any` | `{}` | no |
| <a name="input_node_security_group_tags"></a> [node\_security\_group\_tags](#input\_node\_security\_group\_tags) | List of node security group tags | `any` | `{}` | no |
| <a name="input_openid_connect_audiences"></a> [openid\_connect\_audiences](#input\_openid\_connect\_audiences) | List of OpenID Connect audience client IDs to add to the IRSA provider | `list(string)` | `[]` | no |
Expand Down
25 changes: 25 additions & 0 deletions eks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,31 @@ module "aws-eks-kubernetes-cluster" {
cluster_security_group_additional_rules = merge(local.cluster_security_group_additional_rules, var.cluster_security_group_additional_rules)
node_security_group_additional_rules = merge(local.node_security_group_additional_rules, var.node_security_group_additional_rules)
node_security_group_tags = var.node_security_group_tags
fargate_profiles = var.karpenter_fargate_profile_enabled ? {
karpenter = {
create = true
cluster_name = var.cluster_name
name = local.karpenter_profile_name

subnet_ids = var.subnet_ids
selectors = [
{
namespace = var.karpenter_fargate_profile_namespace
}
]
create_iam_role = var.karpenter_fargate_profile_create_iam_role
iam_role_use_name_prefix = true
iam_role_name = var.cluster_name
iam_role_description = "TrueFoundry IAM role of Karpenter Fargate Profile for cluster ${var.cluster_name}"
iam_role_attach_cni_policy = var.karpenter_fargate_profile_attach_cni_policy
iam_role_tags = local.tags
tags = merge(
{
"faragate-profile" = "karpenter"
}, local.tags
)
}

} : {}
tags = local.tags
}
2 changes: 2 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ locals {
self = true # Does not work for fargate
}
}

karpenter_profile_name = "${var.cluster_name}-karpenter"
}
28 changes: 27 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,35 @@ variable "eks_managed_node_groups" {
##################################################################################
## Other variables
##################################################################################

variable "tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}

##################################################################################
## Karpenter Fargate profile
##################################################################################
variable "karpenter_fargate_profile_enabled" {
description = "Enable Karpenter Fargate profile"
type = bool
default = false
}

variable "karpenter_fargate_profile_namespace" {
description = "value of the namespace where Karpenter is installed"
type = string
default = "karpenter"
}

variable "karpenter_fargate_profile_create_iam_role" {
description = "Create IAM role for Karpenter Fargate profile"
type = bool
default = true
}

variable "karpenter_fargate_profile_attach_cni_policy" {
description = "Attach CNI policy to IAM role for Karpenter Fargate profile"
type = bool
default = true
}

0 comments on commit 84248a4

Please sign in to comment.