Skip to content

Commit 8085535

Browse files
authored
Add defaults for compute cluster configuration (#73)
Signed-off-by: Jim Enright <[email protected]>
1 parent 1792f42 commit 8085535

File tree

6 files changed

+30
-8
lines changed

6 files changed

+30
-8
lines changed

aws/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
| <a name="input_cdp_private_subnet_ids"></a> [cdp\_private\_subnet\_ids](#input\_cdp\_private\_subnet\_ids) | List of private subnet ids. Required if create\_vpc is false. | `list(any)` | `null` | no |
5252
| <a name="input_cdp_public_subnet_ids"></a> [cdp\_public\_subnet\_ids](#input\_cdp\_public\_subnet\_ids) | List of public subnet ids. Required if create\_vpc is false. | `list(any)` | `null` | no |
5353
| <a name="input_cdp_vpc_id"></a> [cdp\_vpc\_id](#input\_cdp\_vpc\_id) | VPC ID for CDP environment. Required if create\_vpc is false. | `string` | `null` | no |
54-
| <a name="input_compute_cluster_configuration"></a> [compute\_cluster\_configuration](#input\_compute\_cluster\_configuration) | Kubernetes configuration for the externalized compute cluster | <pre>object({<br/> kube_api_authorized_ip_ranges = optional(set(string))<br/> outbound_type = optional(string)<br/> private_cluster = optional(bool)<br/> worker_node_subnets = optional(set(string))<br/> })</pre> | `null` | no |
54+
| <a name="input_compute_cluster_configuration"></a> [compute\_cluster\_configuration](#input\_compute\_cluster\_configuration) | Kubernetes configuration for the externalized compute cluster. If not specified, a default configuration suitable for the requested deployment template will be used. | <pre>object({<br/> kube_api_authorized_ip_ranges = optional(set(string))<br/> private_cluster = optional(bool)<br/> worker_node_subnets = optional(set(string))<br/> })</pre> | `null` | no |
5555
| <a name="input_compute_cluster_enabled"></a> [compute\_cluster\_enabled](#input\_compute\_cluster\_enabled) | Enable externalized compute cluster for the environment | `bool` | `false` | no |
5656
| <a name="input_create_vpc"></a> [create\_vpc](#input\_create\_vpc) | Flag to specify if the VPC should be created | `bool` | `true` | no |
5757
| <a name="input_create_vpc_endpoints"></a> [create\_vpc\_endpoints](#input\_create\_vpc\_endpoints) | Flag to specify if VPC Endpoints should be created | `bool` | `true` | no |

aws/main.tf

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ module "cdp_deploy" {
106106
cdp_groups = local.cdp_groups
107107

108108
compute_cluster_enabled = var.compute_cluster_enabled
109-
compute_cluster_configuration = var.compute_cluster_configuration
109+
compute_cluster_configuration = local.compute_cluster_configuration
110110

111111
environment_async_creation = var.environment_async_creation
112112
datalake_async_creation = var.datalake_async_creation
@@ -218,4 +218,15 @@ locals {
218218
add_id_broker_mappings = true
219219
}
220220
])
221-
}
221+
}
222+
223+
# ------- Set default compute cluster configuration if enabled
224+
locals {
225+
compute_cluster_configuration = var.compute_cluster_enabled ? (
226+
var.compute_cluster_configuration != null ? var.compute_cluster_configuration : {
227+
kube_api_authorized_ip_ranges = var.deployment_template == "private" ? null : toset(local.ingress_extra_cidrs_and_ports.cidrs)
228+
worker_node_subnets = var.deployment_template == "public" ? (concat(module.cdp_aws_prereqs.aws_public_subnet_ids, module.cdp_aws_prereqs.aws_private_subnet_ids)) : (module.cdp_aws_prereqs.aws_private_subnet_ids)
229+
private_cluster = var.deployment_template == "private" ? true : false
230+
}
231+
) : null
232+
}

aws/variables.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,11 @@ variable "compute_cluster_enabled" {
181181
variable "compute_cluster_configuration" {
182182
type = object({
183183
kube_api_authorized_ip_ranges = optional(set(string))
184-
outbound_type = optional(string)
185184
private_cluster = optional(bool)
186185
worker_node_subnets = optional(set(string))
187186
})
188187

189-
description = "Kubernetes configuration for the externalized compute cluster"
188+
description = "Kubernetes configuration for the externalized compute cluster. If not specified, a default configuration suitable for the requested deployment template will be used."
190189

191190
default = null
192191
}

azure/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
| <a name="input_cdp_resourcegroup_name"></a> [cdp\_resourcegroup\_name](#input\_cdp\_resourcegroup\_name) | Pre-existing Resource Group for CDP environment. Required if create\_vnet is false. | `string` | `null` | no |
5151
| <a name="input_cdp_subnet_names"></a> [cdp\_subnet\_names](#input\_cdp\_subnet\_names) | List of subnet names for CDP Resources. Required if create\_vnet is false. | `list(any)` | `null` | no |
5252
| <a name="input_cdp_vnet_name"></a> [cdp\_vnet\_name](#input\_cdp\_vnet\_name) | Pre-existing VNet Name for CDP environment. Required if create\_vnet is false. | `string` | `null` | no |
53-
| <a name="input_compute_cluster_configuration"></a> [compute\_cluster\_configuration](#input\_compute\_cluster\_configuration) | Kubernetes configuration for the externalized compute cluster | <pre>object({<br/> kube_api_authorized_ip_ranges = optional(set(string))<br/> outbound_type = optional(string)<br/> private_cluster = optional(bool)<br/> worker_node_subnets = optional(set(string))<br/> })</pre> | `null` | no |
53+
| <a name="input_compute_cluster_configuration"></a> [compute\_cluster\_configuration](#input\_compute\_cluster\_configuration) | Kubernetes configuration for the externalized compute cluster. If not specified, a default configuration suitable for the requested deployment template will be used. | <pre>object({<br/> kube_api_authorized_ip_ranges = optional(set(string))<br/> outbound_type = optional(string)<br/> private_cluster = optional(bool)<br/> worker_node_subnets = optional(set(string))<br/> })</pre> | `null` | no |
5454
| <a name="input_compute_cluster_enabled"></a> [compute\_cluster\_enabled](#input\_compute\_cluster\_enabled) | Enable externalized compute cluster for the environment | `bool` | `false` | no |
5555
| <a name="input_create_vnet"></a> [create\_vnet](#input\_create\_vnet) | Flag to specify if the VNet should be created | `bool` | `true` | no |
5656
| <a name="input_datalake_async_creation"></a> [datalake\_async\_creation](#input\_datalake\_async\_creation) | Flag to specify if Terraform should wait for CDP datalake resource creation/deletion | `bool` | `false` | no |

azure/main.tf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ module "cdp_deploy" {
9595
cdp_groups = local.cdp_groups
9696

9797
compute_cluster_enabled = var.compute_cluster_enabled
98-
compute_cluster_configuration = var.compute_cluster_configuration
98+
compute_cluster_configuration = local.compute_cluster_configuration
9999

100100
environment_async_creation = var.environment_async_creation
101101
datalake_async_creation = var.datalake_async_creation
@@ -205,3 +205,15 @@ locals {
205205
}
206206
])
207207
}
208+
209+
# ------- Set default compute cluster configuration if enabled
210+
locals {
211+
compute_cluster_configuration = var.compute_cluster_enabled ? (
212+
var.compute_cluster_configuration != null ? var.compute_cluster_configuration : {
213+
kube_api_authorized_ip_ranges = var.deployment_template == "private" ? null : toset(local.ingress_extra_cidrs_and_ports.cidrs)
214+
worker_node_subnets = module.cdp_azure_prereqs.azure_cdp_subnet_names
215+
private_cluster = var.deployment_template == "private" ? true : false
216+
outbound_type = ""
217+
}
218+
) : null
219+
}

azure/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ variable "compute_cluster_configuration" {
195195
worker_node_subnets = optional(set(string))
196196
})
197197

198-
description = "Kubernetes configuration for the externalized compute cluster"
198+
description = "Kubernetes configuration for the externalized compute cluster. If not specified, a default configuration suitable for the requested deployment template will be used."
199199

200200
default = null
201201
}

0 commit comments

Comments
 (0)