Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
83ae92e
fix: extract out worker_pool logic
Oct 15, 2025
657d9bc
Merge branch 'main' of https://github.com/terraform-ibm-modules/terra…
Oct 15, 2025
5d69d89
resolve pc
iamar7 Oct 15, 2025
1cc3027
update pr_test
Oct 16, 2025
bb3ec17
Merge branch '16090-cds' of https://github.com/terraform-ibm-modules/…
Oct 16, 2025
a4acda2
added moved block
Oct 17, 2025
134f5c0
Merge branch 'main' into 16090-cds
iamar7 Oct 21, 2025
49cb75a
update tests
Oct 21, 2025
01adf44
update readme
iamar7 Oct 21, 2025
7f9e360
update readme
Oct 21, 2025
3d4b1bc
add worker pool example
Oct 24, 2025
7040b3a
update worker pool example
Oct 24, 2025
0e860f4
update default worker pool
Oct 24, 2025
a25f222
add workerpool example to test
Oct 24, 2025
4acdeeb
Merge branch 'main' into 16090-cds
iamar7 Oct 24, 2025
f68b3bb
resolve comments
Oct 24, 2025
ac0c59a
Merge branch '16090-cds' of https://github.com/terraform-ibm-modules/…
Oct 24, 2025
8a2ec73
update example
Oct 24, 2025
2015d93
Add default value null to prefix variable
iamar7 Oct 24, 2025
9a354da
Remove validation from prefix variable
iamar7 Oct 24, 2025
4143f78
resolve comments
Oct 24, 2025
b22e5c4
Merge branch '16090-cds' of https://github.com/terraform-ibm-modules/…
Oct 24, 2025
9492774
remove worker pool example
Oct 24, 2025
9f7fd8a
resolve pc
iamar7 Oct 24, 2025
bb31898
add worker pool example
Oct 27, 2025
8f44a14
Merge branch '16090-cds' of https://github.com/terraform-ibm-modules/…
Oct 27, 2025
8d008dd
resolve comments
Oct 28, 2025
b7ef0db
update README
Oct 28, 2025
c900e6d
Merge branch 'main' into 16090-cds
iamar7 Oct 28, 2025
4004c59
Merge branch 'main' into 16090-cds
ocofaigh Oct 28, 2025
2200dcf
update cross kms example
Oct 28, 2025
2f07b6e
revert changes
iamar7 Oct 28, 2025
daa451f
remove blank line
iamar7 Oct 28, 2025
f4421f3
remove changes
iamar7 Oct 28, 2025
432a02c
Merge branch 'main' into 16090-cds
iamar7 Oct 29, 2025
16b9e28
update advanced example
iamar7 Oct 29, 2025
f2ddf66
update example
iamar7 Oct 29, 2025
3b6c5cd
Merge branch 'main' into 16090-cds
ocofaigh Oct 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Optionally, the module supports advanced security group management for the worke
* [Submodules](./modules)
* [fscloud](./modules/fscloud)
* [kube-audit](./modules/kube-audit)
* [worker-pool](./modules/worker-pool)
* [Examples](./examples)
* [2 MZR clusters in same VPC example](./examples/multiple_mzr_clusters)
* [Advanced example (mzr, auto-scale, kms, taints)](./examples/advanced)
Expand Down Expand Up @@ -296,6 +297,7 @@ Optionally, you need the following permissions to attach Access Management tags
| <a name="module_cbr_rule"></a> [cbr\_rule](#module\_cbr\_rule) | terraform-ibm-modules/cbr/ibm//modules/cbr-rule-module | 1.33.6 |
| <a name="module_cos_instance"></a> [cos\_instance](#module\_cos\_instance) | terraform-ibm-modules/cos/ibm | 10.5.0 |
| <a name="module_existing_secrets_manager_instance_parser"></a> [existing\_secrets\_manager\_instance\_parser](#module\_existing\_secrets\_manager\_instance\_parser) | terraform-ibm-modules/common-utilities/ibm//modules/crn-parser | 1.2.0 |
| <a name="module_worker_pools"></a> [worker\_pools](#module\_worker\_pools) | ./modules/worker-pool | n/a |

### Resources

Expand All @@ -308,8 +310,6 @@ Optionally, you need the following permissions to attach Access Management tags
| [ibm_container_vpc_cluster.autoscaling_cluster_with_upgrade](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/container_vpc_cluster) | resource |
| [ibm_container_vpc_cluster.cluster](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/container_vpc_cluster) | resource |
| [ibm_container_vpc_cluster.cluster_with_upgrade](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/container_vpc_cluster) | resource |
| [ibm_container_vpc_worker_pool.autoscaling_pool](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/container_vpc_worker_pool) | resource |
| [ibm_container_vpc_worker_pool.pool](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/container_vpc_worker_pool) | resource |
| [ibm_iam_authorization_policy.ocp_secrets_manager_iam_auth_policy](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
| [ibm_resource_tag.cluster_access_tag](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_tag) | resource |
| [ibm_resource_tag.cos_access_tag](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_tag) | resource |
Expand All @@ -322,7 +322,6 @@ Optionally, you need the following permissions to attach Access Management tags
| [ibm_container_addons.existing_addons](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_addons) | data source |
| [ibm_container_cluster_config.cluster_config](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_cluster_config) | data source |
| [ibm_container_cluster_versions.cluster_versions](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_cluster_versions) | data source |
| [ibm_container_vpc_worker_pool.all_pools](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_vpc_worker_pool) | data source |
| [ibm_is_lbs.all_lbs](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/is_lbs) | data source |
| [ibm_is_virtual_endpoint_gateway.api_vpe](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/is_virtual_endpoint_gateway) | data source |
| [ibm_is_virtual_endpoint_gateway.master_vpe](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/is_virtual_endpoint_gateway) | data source |
Expand Down
10 changes: 10 additions & 0 deletions examples/worker_pool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Worker pool example

This example demonstrates how to provision a basic single-zone OCP VPC cluster along with an additional worker pool attached to the cluster.

The following resources are provisioned by this example:

- A new resource group, if an existing one is not passed in.
- A basic VPC and subnet with public gateway enabled.
- A single zone OCP VPC cluster with a default worker pool.
- An additional worker pool attached to the VPC cluster.
96 changes: 96 additions & 0 deletions examples/worker_pool/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
########################################################################################################################
# Resource Group
########################################################################################################################

module "resource_group" {
source = "terraform-ibm-modules/resource-group/ibm"
version = "1.4.0"
# if an existing resource group is not set (null) create a new one using prefix
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
existing_resource_group_name = var.resource_group
}

########################################################################################################################
# VPC + Subnet + Public Gateway
#
# NOTE: This is a very simple VPC with single subnet in a single zone with a public gateway enabled, that will allow
# all traffic ingress/egress by default.
# For production use cases this would need to be enhanced by adding more subnets and zones for resiliency, and
# ACLs/Security Groups for network security.
########################################################################################################################

resource "ibm_is_vpc" "vpc" {
name = "${var.prefix}-vpc"
resource_group = module.resource_group.resource_group_id
address_prefix_management = "auto"
tags = var.resource_tags
}

resource "ibm_is_public_gateway" "gateway" {
name = "${var.prefix}-gateway-1"
vpc = ibm_is_vpc.vpc.id
resource_group = module.resource_group.resource_group_id
zone = "${var.region}-1"
}

resource "ibm_is_subnet" "subnet_zone_1" {
name = "${var.prefix}-subnet-1"
vpc = ibm_is_vpc.vpc.id
resource_group = module.resource_group.resource_group_id
zone = "${var.region}-1"
total_ipv4_address_count = 256
public_gateway = ibm_is_public_gateway.gateway.id
}

########################################################################################################################
# OCP VPC cluster (single zone)
########################################################################################################################

locals {
cluster_vpc_subnets = {
default = [
{
id = ibm_is_subnet.subnet_zone_1.id
cidr_block = ibm_is_subnet.subnet_zone_1.ipv4_cidr_block
zone = ibm_is_subnet.subnet_zone_1.zone
}
]
}

worker_pools = [
{
subnet_prefix = "default"
pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
machine_type = "bx2.4x16"
workers_per_zone = 2 # minimum of 2 is allowed when using single zone
operating_system = "RHCOS"
}
]
}

module "ocp_base" {
source = "../.."
resource_group_id = module.resource_group.resource_group_id
region = var.region
tags = var.resource_tags
cluster_name = var.prefix
force_delete_storage = true
vpc_id = ibm_is_vpc.vpc.id
vpc_subnets = local.cluster_vpc_subnets
ocp_version = var.ocp_version
worker_pools = local.worker_pools
access_tags = var.access_tags
ocp_entitlement = var.ocp_entitlement
disable_outbound_traffic_protection = true # set as True to enable outbound traffic; required for accessing Operator Hub in the OpenShift console.
}



module "worker_pools" {
source = "../../modules/worker-pool"
resource_group_id = module.resource_group.resource_group_id
cluster_id = module.ocp_base.cluster_id
worker_pools = var.worker_pools
vpc_subnets = local.cluster_vpc_subnets
vpc_id = ibm_is_vpc.vpc.id
}
8 changes: 8 additions & 0 deletions examples/worker_pool/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
########################################################################################################################
# Outputs
########################################################################################################################

output "cluster_name" {
value = module.ocp_base.cluster_name
description = "The name of the provisioned cluster."
}
8 changes: 8 additions & 0 deletions examples/worker_pool/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
########################################################################################################################
# Provider config
########################################################################################################################

provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
region = var.region
}
88 changes: 88 additions & 0 deletions examples/worker_pool/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
########################################################################################################################
# Input variables
########################################################################################################################

variable "ibmcloud_api_key" {
type = string
description = "The IBM Cloud api token"
sensitive = true
}

variable "prefix" {
type = string
description = "Prefix for name of all resource created by this example"
validation {
error_message = "Prefix must begin and end with a letter and contain only letters, numbers, and - characters."
condition = can(regex("^([A-z]|[a-z][-a-z0-9]*[a-z0-9])$", var.prefix))
}
}

variable "region" {
type = string
description = "Region where resources are created"
}

variable "resource_group" {
type = string
description = "An existing resource group name to use for this example, if unset a new resource group will be created"
default = null
}

variable "resource_tags" {
type = list(string)
description = "Optional list of tags to be added to created resources"
default = []
}

variable "ocp_version" {
type = string
description = "Version of the OCP cluster to provision"
default = null
}

variable "access_tags" {
type = list(string)
description = "A list of access tags to apply to the resources created by the module."
default = []
}

variable "ocp_entitlement" {
type = string
description = "Value that is applied to the entitlements for OCP cluster provisioning"
default = null
}

variable "worker_pools" {
type = list(object({
subnet_prefix = optional(string)
vpc_subnets = optional(list(object({
id = string
zone = string
cidr_block = string
})))
pool_name = string
machine_type = string
workers_per_zone = number
resource_group_id = optional(string)
operating_system = string
labels = optional(map(string))
minSize = optional(number)
secondary_storage = optional(string)
maxSize = optional(number)
enableAutoscaling = optional(bool)
boot_volume_encryption_kms_config = optional(object({
crk = string
kms_instance_id = string
kms_account_id = optional(string)
}))
additional_security_group_ids = optional(list(string))
}))
description = "List of worker pools"
default = [{
subnet_prefix = "default"
pool_name = "myworkerpool"
machine_type = "bx2.4x16"
operating_system = "RHEL_9_64"
workers_per_zone = 2 # minimum of 2 is allowed when using single zone
}]
}
12 changes: 12 additions & 0 deletions examples/worker_pool/version.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
required_version = ">= 1.9.0"

# Ensure that there is always 1 example locked into the lowest provider version of the range defined in the main
# module's version.tf (basic and add_rules_to_sg), and 1 example that will always use the latest provider version (advanced, fscloud and multiple mzr).
required_providers {
ibm = {
source = "ibm-cloud/ibm"
version = ">= 1.78.2"
}
}
}
Loading