Skip to content

Commit e7ae684

Browse files
authored
fix: add workaround for catalog validation (#318)
1 parent 65c5fe5 commit e7ae684

File tree

7 files changed

+87
-51
lines changed

7 files changed

+87
-51
lines changed

.catalog-onboard-pipeline.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ offerings:
1515
- name: agents
1616
mark_ready: true
1717
install_type: extension
18-
pre_validation: "tests/scripts/pre-validation-deploy-slz-roks-and-obs-instances.sh"
19-
post_validation: "tests/scripts/post-validation-destroy-slz-roks-and-obs-instances.sh"
18+
pre_validation: "tests/scripts/pre-validation-deploy-ocp-and-obs-instances.sh"
19+
post_validation: "tests/scripts/post-validation-destroy-ocp-and-obs-instances.sh"
2020
- name: logs-routing
2121
mark_ready: true
2222
install_type: fullstack

tests/pr_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ func TestAgentsSolutionInSchematics(t *testing.T) {
209209
options.TerraformVars = []testschematic.TestSchematicTerraformVar{
210210
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
211211
{Name: "cloud_monitoring_instance_region", Value: region, DataType: "string"},
212-
{Name: "cluster_id", Value: terraform.Output(t, existingTerraformOptions, "workload_cluster_id"), DataType: "string"},
212+
{Name: "cluster_id", Value: terraform.Output(t, existingTerraformOptions, "cluster_id"), DataType: "string"},
213213
{Name: "logs_agent_trusted_profile", Value: terraform.Output(t, existingTerraformOptions, "trusted_profile_id"), DataType: "string"},
214214
{Name: "cloud_logs_ingress_endpoint", Value: terraform.Output(t, existingTerraformOptions, "cloud_logs_ingress_private_endpoint"), DataType: "string"},
215-
{Name: "cluster_resource_group_id", Value: terraform.Output(t, existingTerraformOptions, "cluster_resource_group_id"), DataType: "string"},
215+
{Name: "cluster_resource_group_id", Value: terraform.Output(t, existingTerraformOptions, "resource_group_id"), DataType: "string"},
216216
{Name: "cloud_monitoring_access_key", Value: terraform.Output(t, existingTerraformOptions, "cloud_monitoring_access_key"), DataType: "string", Secure: true},
217217
{Name: "prefix", Value: options.Prefix, DataType: "string"},
218218
}

tests/resources/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
The terraform code in this directory is used by the tests to provision the following resources:
22

3-
- A VPC landing zone OCP pattern
4-
- Observability instances: Log Analysis and Cloud Monitoring
3+
- A VPC and OCP cluster
4+
- Observability instances: Cloud Logs and Cloud Monitoring

tests/resources/main.tf

Lines changed: 65 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,30 @@ module "resource_group" {
1111
}
1212

1313
##############################################################################
14-
# SLZ ROKS Pattern
14+
# VPC + Subnet + Public Gateway
1515
##############################################################################
1616

17-
module "landing_zone" {
18-
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone//patterns//roks//module?ref=v7.4.4"
19-
region = var.region
20-
prefix = var.prefix
21-
tags = var.resource_tags
22-
add_atracker_route = false
23-
enable_transit_gateway = false
24-
cluster_force_delete_storage = true
25-
verify_cluster_network_readiness = false
26-
use_ibm_cloud_private_api_endpoints = false
27-
ignore_vpcs_for_cluster_deployment = ["management"]
17+
resource "ibm_is_vpc" "vpc" {
18+
name = "${var.prefix}-vpc"
19+
resource_group = module.resource_group.resource_group_id
20+
address_prefix_management = "auto"
21+
tags = var.resource_tags
22+
}
23+
24+
resource "ibm_is_public_gateway" "gateway" {
25+
name = "${var.prefix}-gateway-1"
26+
vpc = ibm_is_vpc.vpc.id
27+
resource_group = module.resource_group.resource_group_id
28+
zone = "${var.region}-1"
29+
}
30+
31+
resource "ibm_is_subnet" "subnet_zone_1" {
32+
name = "${var.prefix}-subnet-1"
33+
vpc = ibm_is_vpc.vpc.id
34+
resource_group = module.resource_group.resource_group_id
35+
zone = "${var.region}-1"
36+
total_ipv4_address_count = 256
37+
public_gateway = ibm_is_public_gateway.gateway.id
2838
}
2939

3040
##############################################################################
@@ -74,15 +84,10 @@ module "buckets" {
7484
# - Monitoring instance
7585
##############################################################################
7686

77-
locals {
78-
cluster_resource_group_id = module.landing_zone.cluster_data["${var.prefix}-workload-cluster"].resource_group_id
79-
cluster_crn = module.landing_zone.cluster_data["${var.prefix}-workload-cluster"].crn
80-
}
81-
8287
module "observability_instances" {
8388
source = "terraform-ibm-modules/observability-instances/ibm"
8489
version = "3.5.0"
85-
resource_group_id = local.cluster_resource_group_id
90+
resource_group_id = module.resource_group.resource_group_id
8691
region = var.region
8792
cloud_monitoring_plan = "graduated-tier"
8893
cloud_monitoring_service_endpoints = "public-and-private"
@@ -131,10 +136,51 @@ module "trusted_profile" {
131136
trusted_profile_links = [{
132137
cr_type = "ROKS_SA"
133138
links = [{
134-
crn = local.cluster_crn
139+
crn = module.ocp_base.cluster_crn
135140
namespace = local.logs_agent_namespace
136141
name = local.logs_agent_name
137142
}]
138143
}
139144
]
140145
}
146+
147+
##############################################################################
148+
# OCP VPC cluster (single zone)
149+
##############################################################################
150+
151+
locals {
152+
cluster_vpc_subnets = {
153+
default = [
154+
{
155+
id = ibm_is_subnet.subnet_zone_1.id
156+
cidr_block = ibm_is_subnet.subnet_zone_1.ipv4_cidr_block
157+
zone = ibm_is_subnet.subnet_zone_1.zone
158+
}
159+
]
160+
}
161+
162+
worker_pools = [
163+
{
164+
subnet_prefix = "default"
165+
pool_name = "default" # ibm_container_vpc_cluster automatically names default pool "default" (See https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2849)
166+
machine_type = "bx2.4x16"
167+
workers_per_zone = 2 # minimum of 2 is allowed when using single zone
168+
operating_system = "REDHAT_8_64"
169+
}
170+
]
171+
}
172+
173+
module "ocp_base" {
174+
source = "terraform-ibm-modules/base-ocp-vpc/ibm"
175+
version = "3.46.1"
176+
resource_group_id = module.resource_group.resource_group_id
177+
region = var.region
178+
tags = var.resource_tags
179+
cluster_name = var.prefix
180+
force_delete_storage = true
181+
use_existing_cos = true
182+
existing_cos_id = module.cos.cos_instance_id
183+
vpc_id = ibm_is_vpc.vpc.id
184+
vpc_subnets = local.cluster_vpc_subnets
185+
worker_pools = local.worker_pools
186+
}

tests/resources/outputs.tf

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,23 @@
33
##############################################################################
44

55
output "prefix" {
6-
value = module.landing_zone.prefix
6+
value = var.prefix
77
description = "prefix"
88
}
99

1010
output "region" {
1111
value = var.region
12-
description = "Region where SLZ ROKS Cluster is deployed."
12+
description = "Region where OCP Cluster is deployed."
1313
}
1414

15-
output "cluster_data" {
16-
value = module.landing_zone.cluster_data
17-
description = "Details of OCP cluster."
15+
output "cluster_id" {
16+
value = module.ocp_base.cluster_id
17+
description = "ID of the cluster."
1818
}
1919

20-
output "workload_cluster_id" {
21-
value = module.landing_zone.workload_cluster_id
22-
description = "ID of the workload cluster."
23-
}
24-
25-
output "workload_cluster_crn" {
26-
value = local.cluster_crn
27-
description = "CRN of the workload cluster."
28-
}
29-
30-
output "cluster_resource_group_id" {
31-
value = local.cluster_resource_group_id
32-
description = "Resource group ID of the workload cluster."
20+
output "resource_group_id" {
21+
value = module.resource_group.resource_group_id
22+
description = "Resource group ID"
3323
}
3424

3525
output "cloud_monitoring_name" {

tests/scripts/post-validation-destroy-slz-roks-and-obs-instances.sh renamed to tests/scripts/post-validation-destroy-ocp-and-obs-instances.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#! /bin/bash
22

33
########################################################################################################################
4-
## This script is used by the catalog pipeline to destroy the SLZ OCP Cluster, which was provisioned as a ##
5-
## prerequisite for the WAS extension that is published to the catalog ##
4+
## This script is used by the catalog pipeline to destroy the OCP Cluster, which was provisioned as a ##
5+
## prerequisite for the Observability agentss DA that is published to the catalog ##
66
########################################################################################################################
77

88
set -e
@@ -12,7 +12,7 @@ TF_VARS_FILE="terraform.tfvars"
1212

1313
(
1414
cd ${TERRAFORM_SOURCE_DIR}
15-
echo "Destroying prerequisite SLZ OCP Cluster and Observability instances .."
15+
echo "Destroying prerequisite OCP Cluster and Observability instances .."
1616
terraform destroy -input=false -auto-approve -var-file=${TF_VARS_FILE} || exit 1
1717
rm -f "${TF_VARS_FILE}"
1818

tests/scripts/pre-validation-deploy-slz-roks-and-obs-instances.sh renamed to tests/scripts/pre-validation-deploy-ocp-and-obs-instances.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#! /bin/bash
22

33
############################################################################################################
4-
## This script is used by the catalog pipeline to deploy the SLZ ROKS and Observability instances,
5-
## which are the prerequisites for the Observability Agents extension.
4+
## This script is used by the catalog pipeline to deploy the OCP cluster and Observability instances,
5+
## which are the prerequisites for the Observability Agents DA.
66
############################################################################################################
77

88
set -e
@@ -16,7 +16,7 @@ TF_VARS_FILE="terraform.tfvars"
1616
(
1717
cwd=$(pwd)
1818
cd ${TERRAFORM_SOURCE_DIR}
19-
echo "Provisioning prerequisite SLZ ROKS CLUSTER and Observability Instances .."
19+
echo "Provisioning prerequisite OCP CLUSTER and Observability instances .."
2020
terraform init || exit 1
2121
# $VALIDATION_APIKEY is available in the catalog runtime
2222
{
@@ -28,9 +28,9 @@ TF_VARS_FILE="terraform.tfvars"
2828

2929
region_var_name="region"
3030
cluster_id_var_name="cluster_id"
31-
cluster_id_value=$(terraform output -state=terraform.tfstate -raw workload_cluster_id)
31+
cluster_id_value=$(terraform output -state=terraform.tfstate -raw cluster_id)
3232
cluster_resource_group_id_var_name="cluster_resource_group_id"
33-
cluster_resource_group_id_value=$(terraform output -state=terraform.tfstate -raw cluster_resource_group_id)
33+
cluster_resource_group_id_value=$(terraform output -state=terraform.tfstate -raw resource_group_id)
3434
cloud_monitoring_instance_region_var_name="cloud_monitoring_instance_region"
3535
cloud_monitoring_access_key_var_name="cloud_monitoring_access_key"
3636
cloud_monitoring_access_key_value=$(terraform output -state=terraform.tfstate -raw cloud_monitoring_access_key)

0 commit comments

Comments
 (0)