Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e881082
feat: add support for install deps
Aashiq-J Nov 14, 2025
9e40a6f
test
Aashiq-J Nov 14, 2025
733a0a7
add variables
Aashiq-J Nov 17, 2025
647d147
Merge branch 'main' of https://github.com/terraform-ibm-modules/terra…
Aashiq-J Nov 17, 2025
ce8cf9e
Merge branch 'main' into install-deps
Aashiq-J Nov 18, 2025
c94e876
update test
Aashiq-J Nov 18, 2025
b0c4803
Merge branch 'main' into install-deps
Aashiq-J Nov 24, 2025
c8f9b34
fix test
Aashiq-J Nov 24, 2025
6d4f942
udpate submodule
Aashiq-J Nov 24, 2025
ba81ae2
update readme
Aashiq-J Nov 24, 2025
612138b
update test
Aashiq-J Nov 24, 2025
9b40676
update script
Aashiq-J Nov 25, 2025
bb310b0
update test
Aashiq-J Nov 25, 2025
f577343
review changes
Aashiq-J Nov 26, 2025
febc4c3
fix
Aashiq-J Nov 26, 2025
05221ac
Merge branch 'main' of https://github.com/terraform-ibm-modules/terra…
Aashiq-J Nov 26, 2025
54d5a4a
update path
Aashiq-J Nov 26, 2025
072276b
test
Aashiq-J Nov 28, 2025
94438e6
test
Aashiq-J Nov 28, 2025
6970512
test
Aashiq-J Nov 28, 2025
f7a4f4c
test
Aashiq-J Nov 28, 2025
68d9001
update
Aashiq-J Dec 1, 2025
f859afd
Merge branch 'main' into install-deps
Aashiq-J Dec 1, 2025
0ca3be5
formatting
Aashiq-J Dec 1, 2025
a5bffb0
update readme
Aashiq-J Dec 1, 2025
9b8e3b6
add triggers
Aashiq-J Dec 1, 2025
b2700c1
review changes
Aashiq-J Dec 1, 2025
9617423
SKIP UPGRADE TEST
Aashiq-J Dec 1, 2025
16cd543
review change
Aashiq-J Dec 1, 2025
55efa37
update path
Aashiq-J Dec 1, 2025
d8ad15a
test kube-audit
Aashiq-J Dec 1, 2025
5cf6740
test path kube-audit
Aashiq-J Dec 1, 2025
c04417a
move script
Aashiq-J Dec 2, 2025
5cca92d
revert kube-audit changes
Aashiq-J Dec 2, 2025
02912da
remove data block
Aashiq-J Dec 2, 2025
546c18a
Merge branch 'main' into install-deps
Aashiq-J Dec 3, 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
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ Optionally, the module supports advanced security group management for the worke

### Before you begin

- Ensure that you have an up-to-date version of the [IBM Cloud CLI](https://cloud.ibm.com/docs/cli?topic=cli-getting-started).
- Ensure that you have an up-to-date version of the [IBM Cloud Kubernetes service CLI](https://cloud.ibm.com/docs/containers?topic=containers-kubernetes-service-cli).
- Ensure that you have an up-to-date version of the [IBM Cloud VPC Infrastructure service CLI](https://cloud.ibm.com/docs/vpc?topic=vpc-vpc-reference). Only required if providing additional security groups with the `var.additional_lb_security_group_ids`.
- Ensure that you have an up-to-date version of the [jq](https://jqlang.github.io/jq).
- Ensure that you have an up-to-date version of the [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl).
- Ensure that you have an up-to-date version of the [oc](https://docs.redhat.com/en/documentation/openshift_container_platform/4.11/html/cli_tools/openshift-cli-oc).

By default, the module automatically downloads the required dependencies if they are not already installed. You can disable this behavior by setting `install_dependencies` to `false`. When enabled, the module fetches dependencies from official online binaries. If you prefer to use third-party repositories, you can specify their URLs by setting the following environment variables: `CUSTOM_KUBECTL_URL`, `CUSTOM_JQ_URL`, and `CUSTOM_OC_URL`.

<!-- Below content is automatically populated via pre-commit hook -->
<!-- BEGIN OVERVIEW HOOK -->
Expand Down Expand Up @@ -323,6 +323,7 @@ Optionally, you need the following permissions to attach Access Management tags
| [kubernetes_config_map_v1_data.set_autoscaling](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/config_map_v1_data) | resource |
| [null_resource.config_map_status](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [null_resource.confirm_network_healthy](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [null_resource.install_dependencies](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [null_resource.ocp_console_management](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [time_sleep.wait_for_auth_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
| [ibm_container_addons.existing_addons](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_addons) | data source |
Expand All @@ -349,6 +350,7 @@ Optionally, you need the following permissions to attach Access Management tags
| <a name="input_cluster_ready_when"></a> [cluster\_ready\_when](#input\_cluster\_ready\_when) | The cluster is ready based on one of the following:: MasterNodeReady (not recommended), OneWorkerNodeReady, Normal, IngressReady | `string` | `"IngressReady"` | no |
| <a name="input_cos_name"></a> [cos\_name](#input\_cos\_name) | Name of the COS instance to provision for OpenShift internal registry storage. New instance only provisioned if 'enable\_registry\_storage' is true and 'use\_existing\_cos' is false. Default: '<cluster\_name>\_cos' | `string` | `null` | no |
| <a name="input_custom_security_group_ids"></a> [custom\_security\_group\_ids](#input\_custom\_security\_group\_ids) | Security groups to add to all worker nodes. This comes in addition to the IBM maintained security group if `attach_ibm_managed_security_group` is set to true. If this variable is set, the default VPC security group is NOT assigned to the worker nodes. | `list(string)` | `null` | no |
| <a name="input_disable_external_binary_download"></a> [disable\_external\_binary\_download](#input\_disable\_external\_binary\_download) | Set this variable to true to prevent the script from downloading binaries from the internet. | `bool` | `false` | no |
| <a name="input_disable_outbound_traffic_protection"></a> [disable\_outbound\_traffic\_protection](#input\_disable\_outbound\_traffic\_protection) | Whether to allow public outbound access from the cluster workers. This is only applicable for OCP 4.15 and later. | `bool` | `false` | no |
| <a name="input_disable_public_endpoint"></a> [disable\_public\_endpoint](#input\_disable\_public\_endpoint) | Whether access to the public service endpoint is disabled when the cluster is created. Does not affect existing clusters. You can't disable a public endpoint on an existing cluster, so you can't convert a public cluster to a private cluster. To change a public endpoint to private, create another cluster with this input set to `true`. | `bool` | `false` | no |
| <a name="input_enable_ocp_console"></a> [enable\_ocp\_console](#input\_enable\_ocp\_console) | Flag to specify whether to enable or disable the OpenShift console. If set to `null` the module does not modify the current setting on the cluster. Keep in mind that when this input is set to `true` or `false` on a cluster with private only endpoint enabled, the runtime must be able to access the private endpoint. | `bool` | `null` | no |
Expand All @@ -359,6 +361,7 @@ Optionally, you need the following permissions to attach Access Management tags
| <a name="input_existing_secrets_manager_instance_crn"></a> [existing\_secrets\_manager\_instance\_crn](#input\_existing\_secrets\_manager\_instance\_crn) | CRN of the Secrets Manager instance where Ingress certificate secrets are stored. If 'enable\_secrets\_manager\_integration' is set to true then this value is required. | `string` | `null` | no |
| <a name="input_force_delete_storage"></a> [force\_delete\_storage](#input\_force\_delete\_storage) | Flag indicating whether or not to delete attached storage when destroying the cluster - Default: false | `bool` | `false` | no |
| <a name="input_ignore_worker_pool_size_changes"></a> [ignore\_worker\_pool\_size\_changes](#input\_ignore\_worker\_pool\_size\_changes) | Enable if using worker autoscaling. Stops Terraform managing worker count | `bool` | `false` | no |
| <a name="input_install_dependencies"></a> [install\_dependencies](#input\_install\_dependencies) | This module includes scripts to support cluster provisioning. Set this variable to true to install all required runtime dependencies. | `bool` | `true` | no |
| <a name="input_kms_config"></a> [kms\_config](#input\_kms\_config) | Use to attach a KMS instance to the cluster. If account\_id is not provided, defaults to the account in use. | <pre>object({<br/> crk_id = string<br/> instance_id = string<br/> private_endpoint = optional(bool, true) # defaults to true<br/> account_id = optional(string) # To attach KMS instance from another account<br/> wait_for_apply = optional(bool, true) # defaults to true so terraform will wait until the KMS is applied to the master, ready and deployed<br/> })</pre> | `null` | no |
| <a name="input_manage_all_addons"></a> [manage\_all\_addons](#input\_manage\_all\_addons) | Instructs Terraform to manage all cluster addons, even if addons were installed outside of the module. If set to 'true' this module destroys any addons that were installed by other sources. | `bool` | `false` | no |
| <a name="input_number_of_lbs"></a> [number\_of\_lbs](#input\_number\_of\_lbs) | The number of LBs to associated the `additional_lb_security_group_names` security group with. | `number` | `1` | no |
Expand Down
21 changes: 18 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ locals {
default_wp_validation = local.rhcos_check ? true : tobool("If RHCOS is used with this cluster, the default worker pool should be created with RHCOS.")
}

resource "null_resource" "install_dependencies" {
count = var.install_dependencies ? 1 : 0
# change trigger to run every time
triggers = {
build_number = timestamp()
}
provisioner "local-exec" {
command = "${path.module}/scripts/install-deps.sh"
interpreter = ["/bin/bash", "-c"]
environment = {
DISABLE_EXTERNAL_DOWNLOADS = var.disable_external_binary_download
}
}
}

# Lookup the current default kube version
data "ibm_container_cluster_versions" "cluster_versions" {
resource_group_id = var.resource_group_id
Expand Down Expand Up @@ -476,7 +491,7 @@ resource "null_resource" "confirm_network_healthy" {
# Worker pool creation can start before the 'ibm_container_vpc_cluster' completes since there is no explicit
# depends_on in 'ibm_container_vpc_worker_pool', just an implicit depends_on on the cluster ID. Cluster ID can exist before
# 'ibm_container_vpc_cluster' completes, so hence need to add explicit depends on against 'ibm_container_vpc_cluster' here.
depends_on = [ibm_container_vpc_cluster.cluster, ibm_container_vpc_cluster.cluster_with_upgrade, ibm_container_vpc_cluster.autoscaling_cluster, ibm_container_vpc_cluster.autoscaling_cluster_with_upgrade, module.worker_pools]
depends_on = [null_resource.install_dependencies, ibm_container_vpc_cluster.cluster, ibm_container_vpc_cluster.cluster_with_upgrade, ibm_container_vpc_cluster.autoscaling_cluster, ibm_container_vpc_cluster.autoscaling_cluster_with_upgrade, module.worker_pools]

provisioner "local-exec" {
command = "${path.module}/scripts/confirm_network_healthy.sh"
Expand All @@ -492,7 +507,7 @@ resource "null_resource" "confirm_network_healthy" {
##############################################################################
resource "null_resource" "ocp_console_management" {
count = var.enable_ocp_console != null ? 1 : 0
depends_on = [null_resource.confirm_network_healthy]
depends_on = [null_resource.install_dependencies, null_resource.confirm_network_healthy]
provisioner "local-exec" {
command = "${path.module}/scripts/enable_disable_ocp_console.sh"
interpreter = ["/bin/bash", "-c"]
Expand Down Expand Up @@ -566,7 +581,7 @@ locals {

resource "null_resource" "config_map_status" {
count = lookup(var.addons, "cluster-autoscaler", null) != null ? 1 : 0
depends_on = [ibm_container_addons.addons]
depends_on = [null_resource.install_dependencies, ibm_container_addons.addons]

provisioner "local-exec" {
command = "${path.module}/scripts/get_config_map_status.sh"
Expand Down
3 changes: 3 additions & 0 deletions modules/kube-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ No modules.
| Name | Type |
|------|------|
| [helm_release.kube_audit](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [null_resource.install_dependencies](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [null_resource.set_audit_log_policy](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [null_resource.set_audit_webhook](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [time_sleep.wait_for_kube_audit](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
Expand All @@ -88,7 +89,9 @@ No modules.
| <a name="input_cluster_config_endpoint_type"></a> [cluster\_config\_endpoint\_type](#input\_cluster\_config\_endpoint\_type) | Specify which type of endpoint to use for for cluster config access: 'default', 'private', 'vpe', 'link'. 'default' value will use the default endpoint of the cluster. | `string` | `"default"` | no |
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | The ID of the cluster to deploy the log collection service in. | `string` | n/a | yes |
| <a name="input_cluster_resource_group_id"></a> [cluster\_resource\_group\_id](#input\_cluster\_resource\_group\_id) | The resource group ID of the cluster. | `string` | n/a | yes |
| <a name="input_disable_external_binary_download"></a> [disable\_external\_binary\_download](#input\_disable\_external\_binary\_download) | Set this variable to true to prevent the script from downloading binaries from the internet. | `bool` | `false` | no |
| <a name="input_ibmcloud_api_key"></a> [ibmcloud\_api\_key](#input\_ibmcloud\_api\_key) | The IBM Cloud api key to generate an IAM token. | `string` | n/a | yes |
| <a name="input_install_dependencies"></a> [install\_dependencies](#input\_install\_dependencies) | This module includes scripts to support cluster provisioning. Set this variable to true to install all required runtime dependencies. | `bool` | `true` | no |
| <a name="input_region"></a> [region](#input\_region) | The IBM Cloud region where the cluster is provisioned. | `string` | n/a | yes |
| <a name="input_use_private_endpoint"></a> [use\_private\_endpoint](#input\_use\_private\_endpoint) | Set this to true to force all api calls to use the IBM Cloud private endpoints. | `bool` | `false` | no |
| <a name="input_wait_till"></a> [wait\_till](#input\_wait\_till) | To avoid long wait times when you run your Terraform code, you can specify the stage when you want Terraform to mark the cluster resource creation as completed. Depending on what stage you choose, the cluster creation might not be fully completed and continues to run in the background. However, your Terraform code can continue to run without waiting for the cluster to be fully created. Supported args are `MasterNodeReady`, `OneWorkerNodeReady`, `IngressReady` and `Normal` | `string` | `"IngressReady"` | no |
Expand Down
20 changes: 18 additions & 2 deletions modules/kube-audit/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
resource "null_resource" "install_dependencies" {
count = var.install_dependencies ? 1 : 0
# change trigger to run every time
triggers = {
build_number = timestamp()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this to trigger every time. It only need to trigger if the null resource has to run again

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess thats not possible, if we set triggers to other null_resource blocks, the install script will run after there is a change in the other null_resource block and not before.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should look into this. I don’t like the fact we will always install as part of every plan. Perhaps there is some pre condition or lifecycle feature we could leverage in terraform?

}
provisioner "local-exec" {
command = "${path.module}/scripts/install-deps.sh"
interpreter = ["/bin/bash", "-c"]
environment = {
DISABLE_EXTERNAL_DOWNLOADS = var.disable_external_binary_download
}
}
}

data "ibm_container_cluster_config" "cluster_config" {
cluster_name_id = var.cluster_id
config_dir = "${path.module}/kubeconfig"
Expand All @@ -19,6 +34,7 @@ locals {
}

resource "null_resource" "set_audit_log_policy" {
depends_on = [null_resource.install_dependencies]
triggers = {
audit_log_policy = var.audit_log_policy
}
Expand All @@ -40,7 +56,7 @@ locals {
}

resource "helm_release" "kube_audit" {
depends_on = [null_resource.set_audit_log_policy, data.ibm_container_vpc_cluster.cluster]
depends_on = [null_resource.install_dependencies, null_resource.set_audit_log_policy, data.ibm_container_vpc_cluster.cluster]
name = var.audit_deployment_name
chart = local.kube_audit_chart_location
timeout = 1200
Expand Down Expand Up @@ -96,7 +112,7 @@ locals {
# }

resource "null_resource" "set_audit_webhook" {
depends_on = [time_sleep.wait_for_kube_audit]
depends_on = [time_sleep.wait_for_kube_audit, null_resource.install_dependencies]
triggers = {
audit_log_policy = var.audit_log_policy
}
Expand Down
2 changes: 2 additions & 0 deletions modules/kube-audit/scripts/confirm-rollout-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -e

export PATH=$PATH:"/tmp"

deployment=$1
namespace=$2

Expand Down
Loading