Skip to content

Commit 9720b23

Browse files
authored
Merge pull request #19 from comet-ml/druid-mng-subnets
Expand subnets, add new MPM compute and new MPM buckets/perms
2 parents 0353ef2 + d59140c commit 9720b23

File tree

9 files changed

+237
-33
lines changed

9 files changed

+237
-33
lines changed

main.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ module "comet_eks" {
7575

7676
s3_enabled = var.enable_s3
7777
comet_ec2_s3_iam_policy = var.enable_s3 ? module.comet_s3[0].comet_s3_iam_policy_arn : null
78+
79+
enable_mpm_infra = var.enable_mpm_infra
80+
81+
eks_druid_instance_type = var.eks_druid_instance_type
82+
eks_druid_node_count = var.eks_druid_node_count
83+
eks_zookeeper_instance_type = var.eks_zookeeper_instance_type
84+
eks_zookeeper_node_count = var.eks_zookeeper_node_count
85+
eks_airflow_instance_type = var.eks_airflow_instance_type
86+
eks_airflow_node_count = var.eks_airflow_node_count
7887
}
7988

8089
module "comet_elasticache" {
@@ -124,6 +133,8 @@ module "comet_s3" {
124133
count = var.enable_s3 ? 1 : 0
125134
environment = var.environment
126135

127-
comet_s3_bucket = var.s3_bucket_name
136+
comet_s3_bucket = var.s3_bucket_name
128137
s3_force_destroy = var.s3_force_destroy
138+
139+
enable_mpm_infra = var.enable_mpm_infra
129140
}

modules/comet_eks/main.tf

Lines changed: 95 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ locals {
33
Terraform = "true"
44
Environment = var.environment
55
}
6+
volume_type = "gp3"
7+
volume_encrypted = false
8+
volume_delete_on_termination = true
69
}
710

811
data "aws_iam_policy" "ebs_csi_policy" {
@@ -22,32 +25,104 @@ module "eks" {
2225

2326
eks_managed_node_group_defaults = { ami_type = var.eks_mng_ami_type }
2427

25-
eks_managed_node_groups = {
26-
one = {
27-
name = var.eks_mng_name
28-
instance_types = var.eks_node_types
29-
min_size = var.eks_mng_desired_size
30-
max_size = var.eks_mng_max_size
31-
desired_size = var.eks_mng_desired_size
32-
block_device_mappings = {
33-
xvda = {
34-
device_name = "/dev/xvda"
35-
ebs = {
36-
volume_size = var.eks_mng_disk_size
37-
volume_type = "gp3"
38-
encrypted = false
39-
delete_on_termination = true
28+
eks_managed_node_groups = merge(
29+
{
30+
comet = {
31+
name = var.eks_mng_name
32+
instance_types = var.eks_node_types
33+
min_size = var.eks_mng_desired_size
34+
max_size = var.eks_mng_max_size
35+
desired_size = var.eks_mng_desired_size
36+
block_device_mappings = {
37+
xvda = {
38+
device_name = "/dev/xvda"
39+
ebs = {
40+
volume_size = var.eks_mng_disk_size
41+
volume_type = local.volume_type
42+
encrypted = local.volume_encrypted
43+
delete_on_termination = local.volume_delete_on_termination
44+
}
4045
}
4146
}
47+
labels = {
48+
nodegroup_name = "comet"
49+
}
50+
iam_role_additional_policies = var.s3_enabled ? { comet_s3_access = var.comet_ec2_s3_iam_policy } : {}
4251
}
43-
44-
iam_role_additional_policies = var.s3_enabled ? { comet_s3_access = var.comet_ec2_s3_iam_policy } : {}
45-
}
46-
}
47-
52+
},
53+
var.enable_mpm_infra ? {
54+
druid = {
55+
name = "druid"
56+
instance_types = [var.eks_druid_instance_type]
57+
min_size = var.eks_druid_node_count
58+
max_size = var.eks_druid_node_count
59+
desired_size = var.eks_druid_node_count
60+
block_device_mappings = {
61+
xvda = {
62+
device_name = "/dev/xvda"
63+
ebs = {
64+
volume_size = var.eks_mng_disk_size
65+
volume_type = local.volume_type
66+
encrypted = local.volume_encrypted
67+
delete_on_termination = local.volume_delete_on_termination
68+
}
69+
}
70+
}
71+
labels = {
72+
nodegroup_name = "druid"
73+
}
74+
iam_role_additional_policies = var.s3_enabled ? { comet_s3_access = var.comet_ec2_s3_iam_policy } : {}
75+
},
76+
zookeeper = {
77+
name = "zookeeper"
78+
instance_types = [var.eks_zookeeper_instance_type]
79+
min_size = var.eks_zookeeper_node_count
80+
max_size = var.eks_zookeeper_node_count
81+
desired_size = var.eks_zookeeper_node_count
82+
block_device_mappings = {
83+
xvda = {
84+
device_name = "/dev/xvda"
85+
ebs = {
86+
volume_size = var.eks_mng_disk_size
87+
volume_type = local.volume_type
88+
encrypted = local.volume_encrypted
89+
delete_on_termination = local.volume_delete_on_termination
90+
}
91+
}
92+
}
93+
labels = {
94+
nodegroup_name = "zookeeper"
95+
}
96+
iam_role_additional_policies = var.s3_enabled ? { comet_s3_access = var.comet_ec2_s3_iam_policy } : {}
97+
},
98+
airflow = {
99+
name = "airflow"
100+
instance_types = [var.eks_airflow_instance_type]
101+
min_size = var.eks_airflow_node_count
102+
max_size = var.eks_airflow_node_count
103+
desired_size = var.eks_airflow_node_count
104+
block_device_mappings = {
105+
xvda = {
106+
device_name = "/dev/xvda"
107+
ebs = {
108+
volume_size = var.eks_mng_disk_size
109+
volume_type = local.volume_type
110+
encrypted = local.volume_encrypted
111+
delete_on_termination = local.volume_delete_on_termination
112+
}
113+
}
114+
}
115+
labels = {
116+
nodegroup_name = "airflow"
117+
}
118+
iam_role_additional_policies = var.s3_enabled ? { comet_s3_access = var.comet_ec2_s3_iam_policy } : {}
119+
}
120+
} : {}
121+
)
48122
tags = local.tags
49123
}
50124

125+
51126
module "irsa-ebs-csi" {
52127
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc"
53128
version = "4.7.0"

modules/comet_eks/variables.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,39 @@ variable "comet_ec2_s3_iam_policy" {
8888
description = "Policy with access to S3 to associate with EKS worker nodes"
8989
type = string
9090
default = null
91+
}
92+
93+
variable "enable_mpm_infra" {
94+
description = "Sets MNGs to be created for MPM compute"
95+
type = bool
96+
}
97+
98+
variable "eks_druid_instance_type" {
99+
description = "Instance type for EKS Druid nodes"
100+
type = string
101+
}
102+
103+
variable "eks_zookeeper_instance_type" {
104+
description = "Instance type for EKS Zookeeper nodes"
105+
type = string
106+
}
107+
108+
variable "eks_airflow_instance_type" {
109+
description = "Instance type for EKS Airflow nodes"
110+
type = string
111+
}
112+
113+
variable "eks_druid_node_count" {
114+
description = "Instance count for EKS Druid nodes"
115+
type = number
116+
}
117+
118+
variable "eks_zookeeper_node_count" {
119+
description = "Instance count for EKS Zookeeper nodes"
120+
type = number
121+
}
122+
123+
variable "eks_airflow_node_count" {
124+
description = "Instance count for EKS Airflow nodes"
125+
type = number
91126
}

modules/comet_s3/main.tf

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ locals {
33
Terraform = "true"
44
Environment = var.environment
55
}
6+
suffix = substr(sha1("${var.environment}"), 0, 8)
67
}
78

89
resource "aws_s3_bucket" "comet_s3_bucket" {
@@ -15,19 +16,52 @@ resource "aws_s3_bucket" "comet_s3_bucket" {
1516
})
1617
}
1718

19+
resource "aws_s3_bucket" "comet_druid_bucket" {
20+
count = var.enable_mpm_infra ? 1 : 0
21+
22+
bucket = "comet-druid-${local.suffix}"
23+
24+
force_destroy = var.s3_force_destroy
25+
26+
tags = merge(local.tags, {
27+
Name = "comet-druid-${local.suffix}"
28+
})
29+
}
30+
31+
resource "aws_s3_bucket" "comet_airflow_bucket" {
32+
count = var.enable_mpm_infra ? 1 : 0
33+
34+
bucket = "comet-airflow-${local.suffix}"
35+
36+
force_destroy = var.s3_force_destroy
37+
38+
tags = merge(local.tags, {
39+
Name = "comet-airflow-${local.suffix}"
40+
})
41+
}
42+
1843
resource "aws_iam_policy" "comet_s3_iam_policy" {
19-
name = "comet-s3-access-policy"
20-
description = "comet-s3-access-policy"
44+
name = "comet-s3-access-policy-${local.suffix}"
45+
description = "Policy for access to comet S3 buckets"
46+
2147
policy = jsonencode({
22-
"Version" : "2012-10-17",
23-
"Statement" : [
48+
Version = "2012-10-17",
49+
Statement = [
2450
{
25-
"Effect" : "Allow",
26-
"Action" : "s3:*",
27-
"Resource" : [
28-
"arn:aws:s3:::${var.comet_s3_bucket}",
29-
"arn:aws:s3:::${var.comet_s3_bucket}/*"
30-
]
51+
Effect = "Allow",
52+
Action = "s3:*",
53+
Resource = concat(
54+
[
55+
aws_s3_bucket.comet_s3_bucket.arn,
56+
"${aws_s3_bucket.comet_s3_bucket.arn}/*"
57+
],
58+
var.enable_mpm_infra ? [
59+
aws_s3_bucket.comet_druid_bucket[0].arn,
60+
"${aws_s3_bucket.comet_druid_bucket[0].arn}/*",
61+
aws_s3_bucket.comet_airflow_bucket[0].arn,
62+
"${aws_s3_bucket.comet_airflow_bucket[0].arn}/*"
63+
] : []
64+
)
3165
}
3266
]
3367
})

modules/comet_s3/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
output "comet_s3_iam_policy_arn" {
2-
description = "ARN of the IAM policy granting access to the provisioned bucket"
2+
description = "ARN of the IAM policy granting access to the provisioned bucket(s)"
33
value = aws_iam_policy.comet_s3_iam_policy.arn
44
}

modules/comet_s3/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@ variable "comet_s3_bucket" {
1111
variable "s3_force_destroy" {
1212
description = "Option to enable force delete of S3 bucket"
1313
type = bool
14+
}
15+
16+
variable "enable_mpm_infra" {
17+
description = "Sets buckets to be created for MPM Druid/Airflow"
18+
type = bool
1419
}

modules/comet_vpc/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module "vpc" {
2020

2121
azs = local.azs
2222
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k)]
23-
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 10)]
23+
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 5, 3 * k + 1)]
2424

2525
enable_nat_gateway = true
2626
enable_dns_hostnames = true

terraform.tfvars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ enable_rds = false
2222
# Create S3 resources for storing Comet objects
2323
enable_s3 = false
2424

25+
# Create EKS nodegroups for MPM compute
26+
enable_mpm_infra = false
27+
2528
################
2629
#### Global ####
2730
################

variables.tf

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ variable "enable_s3" {
3636
type = bool
3737
}
3838

39+
variable "enable_mpm_infra" {
40+
description = "Sets MNGs to be created for MPM compute"
41+
type = bool
42+
}
43+
3944
################
4045
#### Global ####
4146
################
@@ -213,6 +218,42 @@ variable "eks_external_dns_r53_zones" {
213218
]
214219
}
215220

221+
variable "eks_druid_instance_type" {
222+
description = "Instance type for EKS Druid nodes"
223+
type = string
224+
default = "m6i.4xlarge"
225+
}
226+
227+
variable "eks_zookeeper_instance_type" {
228+
description = "Instance type for EKS Zookeeper nodes"
229+
type = string
230+
default = "m6i.4xlarge"
231+
}
232+
233+
variable "eks_airflow_instance_type" {
234+
description = "Instance type for EKS Airflow nodes"
235+
type = string
236+
default = "m6i.4xlarge"
237+
}
238+
239+
variable "eks_druid_node_count" {
240+
description = "Instance count for EKS Druid nodes"
241+
type = number
242+
default = 6
243+
}
244+
245+
variable "eks_zookeeper_node_count" {
246+
description = "Instance count for EKS Zookeeper nodes"
247+
type = number
248+
default = 3
249+
}
250+
251+
variable "eks_airflow_node_count" {
252+
description = "Instance count for EKS Airflow nodes"
253+
type = number
254+
default = 3
255+
}
256+
216257
#### comet_elasticache ####
217258
variable "elasticache_allow_from_sg" {
218259
description = "Security group from which to allow connections to ElastiCache, to use when provisioning with existing compute"

0 commit comments

Comments
 (0)