Skip to content

Commit 8b7101f

Browse files
Merge pull request #4 from truefoundry/support_multiple_role_arns
support multiple role arns in karpenter
2 parents 76f04a4 + 2db25c6 commit 8b7101f

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ Truefoundry AWS Karpenter Module
3838

3939
| Name | Description | Type | Default | Required |
4040
|------|-------------|------|---------|:--------:|
41+
| <a name="input_additional_controller_node_iam_role_arns"></a> [additional\_controller\_node\_iam\_role\_arns](#input\_additional\_controller\_node\_iam\_role\_arns) | The additional node iam roles to be used by karpenter | `list(string)` | `[]` | no |
4142
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Cluster Name to install karpenter | `string` | n/a | yes |
42-
| <a name="input_controller_node_iam_role_arn"></a> [controller\_node\_iam\_role\_arn](#input\_controller\_node\_iam\_role\_arn) | The initial node iam role arn | `string` | n/a | yes |
43+
| <a name="input_controller_node_iam_role_arn"></a> [controller\_node\_iam\_role\_arn](#input\_controller\_node\_iam\_role\_arn) | The node iam role for the initial node group to be used by karpenter | `string` | n/a | yes |
4344
| <a name="input_controller_nodegroup_name"></a> [controller\_nodegroup\_name](#input\_controller\_nodegroup\_name) | The initial nodegroup name | `string` | n/a | yes |
4445
| <a name="input_k8s_service_account_name"></a> [k8s\_service\_account\_name](#input\_k8s\_service\_account\_name) | The k8s karpenter service account name | `string` | n/a | yes |
4546
| <a name="input_k8s_service_account_namespace"></a> [k8s\_service\_account\_namespace](#input\_k8s\_service\_account\_namespace) | The k8s karpenter namespace | `string` | n/a | yes |

main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ module "karpenter_irsa_role" {
77
attach_karpenter_controller_policy = true
88

99
karpenter_controller_cluster_id = var.cluster_name
10-
karpenter_controller_node_iam_role_arns = [var.controller_node_iam_role_arn]
10+
karpenter_controller_node_iam_role_arns = flatten([var.controller_node_iam_role_arn, var.additional_controller_node_iam_role_arns])
1111

1212
attach_vpc_cni_policy = true
1313
vpc_cni_enable_ipv4 = true
14-
14+
1515
role_policy_arns = {
1616
"sqs_policy" = aws_iam_policy.sqs.arn
1717
}

output.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
output "karpenter_role_arn" {
2-
value = module.karpenter_irsa_role.iam_role_arn
2+
value = module.karpenter_irsa_role.iam_role_arn
33
description = "Karpenter role ARN"
44
}
55

66
output "karpenter_instance_profile_id" {
7-
value = aws_iam_instance_profile.karpenter.id
7+
value = aws_iam_instance_profile.karpenter.id
88
description = "Karpenter instance profile ID"
99
}
1010

1111
output "karpenter_sqs_name" {
12-
value = aws_sqs_queue.karpenter.name
12+
value = aws_sqs_queue.karpenter.name
1313
description = "Name of the SQS queue for interruption handling"
1414
}

sqs.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
resource "aws_sqs_queue" "karpenter" {
22
name = "${var.cluster_name}-karpenter"
33
message_retention_seconds = var.message_retention_seconds
4-
sqs_managed_sse_enabled = var.sqs_enable_encryption
5-
tags = local.tags
4+
sqs_managed_sse_enabled = var.sqs_enable_encryption
5+
tags = local.tags
66
}
77

88
data "aws_iam_policy_document" "sqs" {

variables.tf

+11-5
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,30 @@ variable "oidc_provider_arn" {
1919
}
2020

2121
variable "controller_node_iam_role_arn" {
22-
description = "The initial node iam role arn"
22+
description = "The node iam role for the initial node group to be used by karpenter"
2323
type = string
2424
}
2525

26+
variable "additional_controller_node_iam_role_arns" {
27+
description = "The additional node iam roles to be used by karpenter"
28+
type = list(string)
29+
default = []
30+
}
31+
2632
variable "controller_nodegroup_name" {
2733
description = "The initial nodegroup name"
2834
type = string
2935
}
3036
variable "sqs_enable_encryption" {
3137
description = "Enable Server side encryption for SQS"
32-
type = bool
33-
default = true
38+
type = bool
39+
default = true
3440
}
3541

3642
variable "message_retention_seconds" {
3743
description = "Message retention in seconds for SQS queue"
38-
type = number
39-
default = 300
44+
type = number
45+
default = 300
4046
}
4147

4248
variable "tags" {

0 commit comments

Comments
 (0)