Skip to content

Commit 92909de

Browse files
authored
feat: added support to provision the openshift-ai cluster add-on (#615)
1 parent aeb7c65 commit 92909de

File tree

5 files changed

+47
-3
lines changed

5 files changed

+47
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ Optionally, you need the following permissions to attach Access Management tags
285285
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | A list of access tags to apply to the resources created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details | `list(string)` | `[]` | no |
286286
| <a name="input_additional_lb_security_group_ids"></a> [additional\_lb\_security\_group\_ids](#input\_additional\_lb\_security\_group\_ids) | Additional security groups to add to the load balancers associated with the cluster. Ensure that the number\_of\_lbs is set to the number of LBs associated with the cluster. This comes in addition to the IBM maintained security group. | `list(string)` | `[]` | no |
287287
| <a name="input_additional_vpe_security_group_ids"></a> [additional\_vpe\_security\_group\_ids](#input\_additional\_vpe\_security\_group\_ids) | Additional security groups to add to all existing load balancers. This comes in addition to the IBM maintained security group. | <pre>object({<br/> master = optional(list(string), [])<br/> registry = optional(list(string), [])<br/> api = optional(list(string), [])<br/> })</pre> | `{}` | no |
288-
| <a name="input_addons"></a> [addons](#input\_addons) | Map of OCP cluster add-on versions to install (NOTE: The 'vpc-block-csi-driver' add-on is installed by default for VPC clusters and 'ibm-storage-operator' is installed by default in OCP 4.15 and later, however you can explicitly specify it here if you wish to choose a later version than the default one). For full list of all supported add-ons and versions, see https://cloud.ibm.com/docs/containers?topic=containers-supported-cluster-addon-versions | <pre>object({<br/> debug-tool = optional(string)<br/> image-key-synchronizer = optional(string)<br/> openshift-data-foundation = optional(string)<br/> vpc-file-csi-driver = optional(string)<br/> static-route = optional(string)<br/> cluster-autoscaler = optional(string)<br/> vpc-block-csi-driver = optional(string)<br/> ibm-storage-operator = optional(string)<br/> })</pre> | `{}` | no |
288+
| <a name="input_addons"></a> [addons](#input\_addons) | Map of OCP cluster add-on versions to install (NOTE: The 'vpc-block-csi-driver' add-on is installed by default for VPC clusters and 'ibm-storage-operator' is installed by default in OCP 4.15 and later, however you can explicitly specify it here if you wish to choose a later version than the default one). For full list of all supported add-ons and versions, see https://cloud.ibm.com/docs/containers?topic=containers-supported-cluster-addon-versions | <pre>object({<br/> debug-tool = optional(string)<br/> image-key-synchronizer = optional(string)<br/> openshift-data-foundation = optional(string)<br/> vpc-file-csi-driver = optional(string)<br/> static-route = optional(string)<br/> cluster-autoscaler = optional(string)<br/> vpc-block-csi-driver = optional(string)<br/> ibm-storage-operator = optional(string)<br/> openshift-ai = optional(string)<br/> })</pre> | `{}` | no |
289289
| <a name="input_allow_default_worker_pool_replacement"></a> [allow\_default\_worker\_pool\_replacement](#input\_allow\_default\_worker\_pool\_replacement) | (Advanced users) Set to true to allow the module to recreate a default worker pool. If you wish to make any change to the default worker pool which requires the re-creation of the default pool follow these [steps](https://github.com/terraform-ibm-modules/terraform-ibm-base-ocp-vpc?tab=readme-ov-file#important-considerations-for-terraform-and-default-worker-pool). | `bool` | `false` | no |
290290
| <a name="input_attach_ibm_managed_security_group"></a> [attach\_ibm\_managed\_security\_group](#input\_attach\_ibm\_managed\_security\_group) | Specify whether to attach the IBM-defined default security group (whose name is kube-<clusterid>) to all worker nodes. Only applicable if custom\_security\_group\_ids is set. | `bool` | `true` | no |
291291
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | The list of context-based restriction rules to create. | <pre>list(object({<br/> description = string<br/> account_id = string<br/> rule_contexts = list(object({<br/> attributes = optional(list(object({<br/> name = string<br/> value = string<br/> }))) }))<br/> enforcement_mode = string<br/> tags = optional(list(object({<br/> name = string<br/> value = string<br/> })), [])<br/> operations = optional(list(object({<br/> api_types = list(object({<br/> api_type_id = string<br/> }))<br/> })))<br/> }))</pre> | `[]` | no |

main.tf

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,28 @@ locals {
4141
disable_outbound_traffic_protection = startswith(local.ocp_version, "4.14") ? null : var.disable_outbound_traffic_protection
4242
}
4343

44+
# Local block to verify validations for OCP AI Addon.
45+
locals {
46+
47+
# get the total workers per pool
48+
workers_per_pool = {
49+
for pool in var.worker_pools :
50+
pool.pool_name => (
51+
pool.vpc_subnets != null ? length(pool.vpc_subnets) * pool.workers_per_zone : length(var.vpc_subnets[pool.subnet_prefix]) * pool.workers_per_zone
52+
)
53+
}
54+
55+
# retrieve worker specs (CPU & RAM) for all worker pools
56+
worker_specs = {
57+
for pool in var.worker_pools :
58+
pool.pool_name => {
59+
cpu_count = tonumber(split("x", split(".", pool.machine_type)[1])[0])
60+
ram_count = tonumber(split("x", split(".", pool.machine_type)[1])[1])
61+
is_gpu = contains(["gx2", "gx3", "gx4"], split(".", pool.machine_type)[0])
62+
}
63+
}
64+
}
65+
4466
# Separate local block to handle os validations
4567
locals {
4668
os_rhel = "REDHAT_8_64"
@@ -463,7 +485,6 @@ resource "null_resource" "confirm_network_healthy" {
463485
resource "null_resource" "ocp_console_management" {
464486
count = var.enable_ocp_console != null ? 1 : 0
465487
depends_on = [null_resource.confirm_network_healthy]
466-
467488
provisioner "local-exec" {
468489
command = "${path.module}/scripts/enable_disable_ocp_console.sh"
469490
interpreter = ["/bin/bash", "-c"]

modules/fscloud/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ No resources.
115115
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | A list of access tags to apply to the resources created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details | `list(string)` | `[]` | no |
116116
| <a name="input_additional_lb_security_group_ids"></a> [additional\_lb\_security\_group\_ids](#input\_additional\_lb\_security\_group\_ids) | Additional security groups to add to the load balancers associated with the cluster. Ensure that the number\_of\_lbs is set to the number of LBs associated with the cluster. This comes in addition to the IBM maintained security group. | `list(string)` | `[]` | no |
117117
| <a name="input_additional_vpe_security_group_ids"></a> [additional\_vpe\_security\_group\_ids](#input\_additional\_vpe\_security\_group\_ids) | Additional security groups to add to all existing load balancers. This comes in addition to the IBM maintained security group. | <pre>object({<br/> master = optional(list(string), [])<br/> registry = optional(list(string), [])<br/> api = optional(list(string), [])<br/> })</pre> | `{}` | no |
118-
| <a name="input_addons"></a> [addons](#input\_addons) | Map of OCP cluster add-on versions to install (NOTE: The 'vpc-block-csi-driver' add-on is installed by default for VPC clusters and 'ibm-storage-operator' is installed by default in OCP 4.15 and later, however you can explicitly specify it here if you wish to choose a later version than the default one). For full list of all supported add-ons and versions, see https://cloud.ibm.com/docs/containers?topic=containers-supported-cluster-addon-versions | <pre>object({<br/> debug-tool = optional(string)<br/> image-key-synchronizer = optional(string)<br/> openshift-data-foundation = optional(string)<br/> vpc-file-csi-driver = optional(string)<br/> static-route = optional(string)<br/> cluster-autoscaler = optional(string)<br/> vpc-block-csi-driver = optional(string)<br/> ibm-storage-operator = optional(string)<br/> })</pre> | `{}` | no |
118+
| <a name="input_addons"></a> [addons](#input\_addons) | Map of OCP cluster add-on versions to install (NOTE: The 'vpc-block-csi-driver' add-on is installed by default for VPC clusters and 'ibm-storage-operator' is installed by default in OCP 4.15 and later, however you can explicitly specify it here if you wish to choose a later version than the default one). For full list of all supported add-ons and versions, see https://cloud.ibm.com/docs/containers?topic=containers-supported-cluster-addon-versions | <pre>object({<br/> debug-tool = optional(string)<br/> image-key-synchronizer = optional(string)<br/> openshift-data-foundation = optional(string)<br/> vpc-file-csi-driver = optional(string)<br/> static-route = optional(string)<br/> cluster-autoscaler = optional(string)<br/> vpc-block-csi-driver = optional(string)<br/> ibm-storage-operator = optional(string)<br/> openshift-ai = optional(string)<br/> })</pre> | `{}` | no |
119119
| <a name="input_allow_default_worker_pool_replacement"></a> [allow\_default\_worker\_pool\_replacement](#input\_allow\_default\_worker\_pool\_replacement) | (Advanced users) Set to true to allow the module to recreate a default worker pool. Only use in the case where you are getting an error indicating that the default worker pool cannot be replaced on apply. Once the default worker pool is handled as a stand-alone ibm\_container\_vpc\_worker\_pool, if you wish to make any change to the default worker pool which requires the re-creation of the default pool set this variable to true. | `bool` | `false` | no |
120120
| <a name="input_attach_ibm_managed_security_group"></a> [attach\_ibm\_managed\_security\_group](#input\_attach\_ibm\_managed\_security\_group) | Specify whether to attach the IBM-defined default security group (whose name is kube-<clusterid>) to all worker nodes. Only applicable if custom\_security\_group\_ids is set. | `bool` | `true` | no |
121121
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | The list of context-based restriction rules to create. | <pre>list(object({<br/> description = string<br/> account_id = string<br/> rule_contexts = list(object({<br/> attributes = optional(list(object({<br/> name = string<br/> value = string<br/> }))) }))<br/> enforcement_mode = string<br/> tags = optional(list(object({<br/> name = string<br/> value = string<br/> })), [])<br/> operations = optional(list(object({<br/> api_types = list(object({<br/> api_type_id = string<br/> }))<br/> })))<br/> }))</pre> | `[]` | no |

modules/fscloud/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ variable "addons" {
159159
cluster-autoscaler = optional(string)
160160
vpc-block-csi-driver = optional(string)
161161
ibm-storage-operator = optional(string)
162+
openshift-ai = optional(string)
162163
})
163164
description = "Map of OCP cluster add-on versions to install (NOTE: The 'vpc-block-csi-driver' add-on is installed by default for VPC clusters and 'ibm-storage-operator' is installed by default in OCP 4.15 and later, however you can explicitly specify it here if you wish to choose a later version than the default one). For full list of all supported add-ons and versions, see https://cloud.ibm.com/docs/containers?topic=containers-supported-cluster-addon-versions"
164165
default = {}

variables.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,32 @@ variable "addons" {
318318
cluster-autoscaler = optional(string)
319319
vpc-block-csi-driver = optional(string)
320320
ibm-storage-operator = optional(string)
321+
openshift-ai = optional(string)
321322
})
322323
description = "Map of OCP cluster add-on versions to install (NOTE: The 'vpc-block-csi-driver' add-on is installed by default for VPC clusters and 'ibm-storage-operator' is installed by default in OCP 4.15 and later, however you can explicitly specify it here if you wish to choose a later version than the default one). For full list of all supported add-ons and versions, see https://cloud.ibm.com/docs/containers?topic=containers-supported-cluster-addon-versions"
323324
nullable = false
324325
default = {}
326+
327+
validation {
328+
condition = lookup(var.addons, "openshift-ai", null) == null || (tonumber(local.ocp_version_num) >= 4.16)
329+
error_message = "OCP AI add-on requires OCP version >= 4.16.0"
330+
}
331+
332+
validation {
333+
condition = lookup(var.addons, "openshift-ai", null) == null || alltrue([for workers in values(local.workers_per_pool) : workers >= 2])
334+
error_message = "OCP AI add-on requires at least 2 worker nodes in each worker pool."
335+
}
336+
337+
validation {
338+
condition = lookup(var.addons, "openshift-ai", null) == null || alltrue([for spec in values(local.worker_specs) : spec.cpu_count >= 8 && spec.ram_count >= 32])
339+
error_message = "To install OCP AI add-on, all worker nodes in all pools must have at least 8-core CPU and 32GB memory."
340+
}
341+
342+
validation {
343+
condition = lookup(var.addons, "openshift-ai", null) == null || anytrue([for pool in var.worker_pools : lookup(local.worker_specs[pool.pool_name], "is_gpu", false)])
344+
error_message = "OCP AI add-on requires at least one GPU-enabled worker pool."
345+
}
346+
325347
}
326348

327349
variable "manage_all_addons" {

0 commit comments

Comments
 (0)