Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ You need the following permissions to run this module.
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.79.1, <2.0.0 |
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.16.1, < 3.0.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.2.1, < 4.0.0 |
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9.1, < 1.0.0 |

### Modules

Expand All @@ -136,7 +135,7 @@ No modules.
| [null_resource.enable_catalog_source](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [null_resource.storageprofile_status](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [null_resource.update_storage_profile](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [time_sleep.wait_for_subscription](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
| [null_resource.wait_for_crd](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
| [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_vpc_cluster.cluster](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/data-sources/container_vpc_cluster) | data source |

Expand Down
15 changes: 12 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,23 @@ locals {
operator_chart_location = "${path.module}/chart/operator"
}

resource "time_sleep" "wait_for_subscription" {

resource "null_resource" "wait_for_crd" {
depends_on = [helm_release.subscription]

create_duration = "240s"
provisioner "local-exec" {

command = "${path.module}/scripts/confirm-operator-installation.sh"
interpreter = ["/bin/bash", "-c"]
environment = {
KUBECONFIG = data.ibm_container_cluster_config.cluster_config.config_file_path
}
}
}


resource "helm_release" "operator" {
depends_on = [time_sleep.wait_for_subscription]
depends_on = [null_resource.wait_for_crd]
name = "${data.ibm_container_vpc_cluster.cluster.name}-operator"
chart = local.operator_chart_location
namespace = local.namespace
Expand Down
48 changes: 48 additions & 0 deletions scripts/confirm-operator-installation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
set -e

echo "Waiting for install plan to be created"
sleep 120


for i in {1..30}; do
if kubectl get installplan -n openshift-cnv | grep kubevirt-hyperconverged | grep -q true; then
echo "✅ Install plan is ready and approved"
break
fi
echo "waiting for installplan to be ready"
sleep 10
done

for i in {1..10}; do
echo "Attempt $i: waiting for hco-operator deployment to become Available..."
if kubectl wait --for=condition=available deployment/hco-operator -n openshift-cnv --timeout=5m >/dev/null 2>&1; then
echo "✅ hco-operator deployment is Available"
break
fi
echo "Still not available, retrying... ($i)"
sleep 10
done

for i in {1..10}; do
echo "Attempt $i: waiting for hco-webhook deployment to become Available..."
if kubectl wait --for=condition=available deployment/hco-webhook -n openshift-cnv --timeout=5m >/dev/null 2>&1; then
echo "✅ hco-webhook deployment is Available"
break
fi
echo "Still not available, retrying... ($i)"
sleep 10
done


for i in {1..10}; do
echo "Attempt $i: waiting for HyperConverged CRD to be available..."
if kubectl get crd hyperconvergeds.hco.kubevirt.io >/dev/null 2>&1; then
echo "✅ HyperConverged CRD is available"
break
fi
echo "CRD not ready yet, retrying... ($i)"
sleep 10
done

echo "✅ Proceeding to Custom Resource creation"
4 changes: 0 additions & 4 deletions version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,5 @@ terraform {
source = "hashicorp/kubernetes"
version = ">= 2.16.1, < 3.0.0"
}
time = {
source = "hashicorp/time"
version = ">= 0.9.1, < 1.0.0"
}
}
}