Skip to content

Commit 7dd440a

Browse files
feat: added support to the DA to wait till cluster is ready before deploying it using new inputs wait_till, wait_till_timeout and is_vpc_cluster (#168)
1 parent 9fdf8eb commit 7dd440a

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

solutions/agents/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
##############################################################################
44

55
data "ibm_container_cluster_config" "cluster_config" {
6-
cluster_name_id = var.cluster_id
6+
cluster_name_id = var.is_vpc_cluster ? data.ibm_container_vpc_cluster.cluster[0].name : data.ibm_container_cluster.cluster[0].name
77
resource_group_id = var.cluster_resource_group_id
88
config_dir = "${path.module}/kubeconfig"
99
endpoint_type = var.cluster_config_endpoint_type != "default" ? var.cluster_config_endpoint_type : null

solutions/agents/provider.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,19 @@ provider "helm" {
1313
token = data.ibm_container_cluster_config.cluster_config.token
1414
}
1515
}
16+
17+
# Retrieve information about an existing VPC cluster
18+
data "ibm_container_vpc_cluster" "cluster" {
19+
count = var.is_vpc_cluster ? 1 : 0
20+
name = var.cluster_id
21+
wait_till = var.wait_till
22+
wait_till_timeout = var.wait_till_timeout
23+
}
24+
25+
# Retrieve information about an existing Classic cluster
26+
data "ibm_container_cluster" "cluster" {
27+
count = var.is_vpc_cluster ? 0 : 1
28+
name = var.cluster_id
29+
wait_till = var.wait_till
30+
wait_till_timeout = var.wait_till_timeout
31+
}

solutions/agents/variables.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,34 @@ variable "cluster_config_endpoint_type" {
3535
}
3636
}
3737

38+
variable "is_vpc_cluster" {
39+
type = bool
40+
description = "Specify true if the target cluster for the DA is a VPC cluster, false if it is classic cluster."
41+
default = true
42+
}
43+
44+
variable "wait_till" {
45+
description = "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`"
46+
type = string
47+
default = "Normal"
48+
49+
validation {
50+
error_message = "`wait_till` value must be one of `MasterNodeReady`, `OneWorkerNodeReady`, `IngressReady` or `Normal`."
51+
condition = contains([
52+
"MasterNodeReady",
53+
"OneWorkerNodeReady",
54+
"IngressReady",
55+
"Normal"
56+
], var.wait_till)
57+
}
58+
}
59+
60+
variable "wait_till_timeout" {
61+
description = "Timeout for wait_till in minutes."
62+
type = number
63+
default = 90
64+
}
65+
3866
##############################################################################
3967
# Log Analysis variables
4068
##############################################################################

0 commit comments

Comments
 (0)