Skip to content

Commit 29ce6ef

Browse files
Merge pull request #7632 from cjschaef/splat-1097
CORS-2933: IBMCloud: Basic service endpoint override
2 parents 77a6bb5 + 8909227 commit 29ce6ef

39 files changed

+1223
-143
lines changed

data/data/ibmcloud/bootstrap/common.tf

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
locals {
2-
description = "Created By OpenShift Installer"
3-
public_endpoints = var.ibmcloud_publish_strategy == "External" ? true : false
2+
description = "Created By OpenShift Installer"
3+
# If any Service Endpoints are being overridden, set visibility to 'private'
4+
# for IBM Terraform Provider to use the endpoints JSON file.
5+
endpoint_visibility = var.ibmcloud_endpoints_json_file != "" ? "private" : "public"
6+
public_endpoints = var.ibmcloud_publish_strategy == "External" ? true : false
47
tags = concat(
58
["kubernetes.io_cluster_${var.cluster_id}:owned"],
69
var.ibmcloud_extra_tags
@@ -14,4 +17,8 @@ locals {
1417
provider "ibm" {
1518
ibmcloud_api_key = var.ibmcloud_api_key
1619
region = var.ibmcloud_region
17-
}
20+
21+
# Manage endpoints for IBM Cloud services
22+
visibility = local.endpoint_visibility
23+
endpoints_file_path = var.ibmcloud_endpoints_json_file
24+
}

data/data/ibmcloud/bootstrap/ignition.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
locals {
2+
# Use the direct COS endpoint if IBM Cloud Service Endpoints are being overridden,
3+
# as public and private may not be available. The direct endpoint requires
4+
# additional IBM Cloud Account configuration, which must be configured when using
5+
# Service Endpoint overrides.
6+
cos_endpoint_type = local.endpoint_visibility == "private" ? "direct" : "public"
7+
}
8+
19
############################################
210
# COS bucket
311
############################################
412

513
resource "ibm_cos_bucket" "bootstrap_ignition" {
614
bucket_name = "${local.prefix}-bootstrap-ignition"
15+
endpoint_type = local.cos_endpoint_type
716
resource_instance_id = var.cos_resource_instance_crn
817
region_location = var.ibmcloud_region
918
storage_class = "smart"
@@ -16,9 +25,10 @@ resource "ibm_cos_bucket" "bootstrap_ignition" {
1625
resource "ibm_cos_bucket_object" "bootstrap_ignition" {
1726
bucket_crn = ibm_cos_bucket.bootstrap_ignition.crn
1827
bucket_location = ibm_cos_bucket.bootstrap_ignition.region_location
19-
key = "bootstrap.ign"
2028
content_file = var.ignition_bootstrap_file
29+
endpoint_type = local.cos_endpoint_type
2130
etag = filemd5(var.ignition_bootstrap_file)
31+
key = "bootstrap.ign"
2232
}
2333

2434
############################################

data/data/ibmcloud/master/common.tf

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
locals {
2-
description = "Created By OpenShift Installer"
3-
public_endpoints = var.ibmcloud_publish_strategy == "External" ? true : false
2+
description = "Created By OpenShift Installer"
3+
# If any Service Endpoints are being overridden, set visibility to 'private'
4+
# for IBM Terraform Provider to use the endpoints JSON file.
5+
endpoint_visibility = var.ibmcloud_endpoints_json_file != "" ? "private" : "public"
6+
public_endpoints = var.ibmcloud_publish_strategy == "External" ? true : false
47
tags = concat(
58
["kubernetes.io_cluster_${var.cluster_id}:owned"],
69
var.ibmcloud_extra_tags
@@ -14,4 +17,8 @@ locals {
1417
provider "ibm" {
1518
ibmcloud_api_key = var.ibmcloud_api_key
1619
region = var.ibmcloud_region
17-
}
20+
21+
# Manage endpoints for IBM Cloud services
22+
visibility = local.endpoint_visibility
23+
endpoints_file_path = var.ibmcloud_endpoints_json_file
24+
}

data/data/ibmcloud/network/common.tf

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
locals {
2-
description = "Created By OpenShift Installer"
3-
public_endpoints = var.ibmcloud_publish_strategy == "External" ? true : false
2+
description = "Created By OpenShift Installer"
3+
# If any Service Endpoints are being overridden, set visibility to 'private'
4+
# for IBM Terraform Provider to use the endpoints JSON file.
5+
endpoint_visibility = var.ibmcloud_endpoints_json_file != "" ? "private" : "public"
6+
public_endpoints = var.ibmcloud_publish_strategy == "External" ? true : false
47
tags = concat(
58
["kubernetes.io_cluster_${var.cluster_id}:owned"],
69
var.ibmcloud_extra_tags
@@ -14,4 +17,8 @@ locals {
1417
provider "ibm" {
1518
ibmcloud_api_key = var.ibmcloud_api_key
1619
region = var.ibmcloud_region
17-
}
20+
21+
# Manage endpoints for IBM Cloud services
22+
visibility = local.endpoint_visibility
23+
endpoints_file_path = var.ibmcloud_endpoints_json_file
24+
}

data/data/ibmcloud/network/image/main.tf

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
locals {
2-
prefix = var.cluster_id
2+
# Use the direct COS endpoint if IBM Cloud Service Endpoints are being overridden,
3+
# as public and private may not be available. The direct endpoint requires
4+
# additional IBM Cloud Account configuration, which must be configured when using
5+
# Service Endpoint overrides.
6+
cos_endpoint_type = var.endpoint_visibility == "private" ? "direct" : "public"
7+
prefix = var.cluster_id
38
}
49

510
resource "ibm_cos_bucket" "images" {
6-
bucket_name = "${local.prefix}-vsi-image"
11+
bucket_name = "${local.prefix}-vsi-image"
12+
# Use the direct COS endpoint if IBM Cloud Service endpoints are being overridden,
13+
# as public and private may not be available. Direct requires additional IBM Cloud
14+
# Account configuration
15+
endpoint_type = local.cos_endpoint_type
716
resource_instance_id = var.cos_resource_instance_crn
817
region_location = var.region
918
storage_class = "smart"
@@ -13,6 +22,7 @@ resource "ibm_cos_bucket_object" "file" {
1322
bucket_crn = ibm_cos_bucket.images.crn
1423
bucket_location = ibm_cos_bucket.images.region_location
1524
content_file = var.image_filepath
25+
endpoint_type = local.cos_endpoint_type
1626
key = basename(var.image_filepath)
1727
}
1828

data/data/ibmcloud/network/image/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ variable "tags" {
2525
variable "cos_resource_instance_crn" {
2626
type = string
2727
}
28+
29+
variable "endpoint_visibility" {
30+
type = string
31+
}

data/data/ibmcloud/network/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ module "image" {
4848
resource_group_id = local.resource_group_id
4949
tags = local.tags
5050
cos_resource_instance_crn = ibm_resource_instance.cos.crn
51+
endpoint_visibility = local.endpoint_visibility
5152
}
5253

5354
############################################

data/data/ibmcloud/variables-ibmcloud.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ variable "ibmcloud_image_filepath" {
5555
# Top-level module variables (optional)
5656
#######################################
5757

58+
variable "ibmcloud_endpoints_json_file" {
59+
type = string
60+
description = "JSON file containing IBM Cloud service endpoints"
61+
default = ""
62+
}
63+
5864
variable "ibmcloud_preexisting_vpc" {
5965
type = bool
6066
description = "Specifies whether an existing VPC should be used or a new one created for installation."

data/data/install.openshift.io_installconfigs.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3364,6 +3364,49 @@ spec:
33643364
resource group where the cluster should be installed. If empty,
33653365
a new resource group will be created for the cluster.
33663366
type: string
3367+
serviceEndpoints:
3368+
description: ServiceEndpoints is a list which contains custom
3369+
endpoints to override default service endpoints of IBM Cloud
3370+
Services. There must only be one ServiceEndpoint for a service
3371+
(no duplicates).
3372+
items:
3373+
description: IBMCloudServiceEndpoint stores the configuration
3374+
of a custom url to override existing defaults of IBM Cloud
3375+
Services.
3376+
properties:
3377+
name:
3378+
description: 'name is the name of the IBM Cloud service.
3379+
Possible values are: CIS, COS, DNSServices, GlobalSearch,
3380+
GlobalTagging, HyperProtect, IAM, KeyProtect, ResourceController,
3381+
ResourceManager, or VPC. For example, the IBM Cloud Private
3382+
IAM service could be configured with the service `name`
3383+
of `IAM` and `url` of `https://private.iam.cloud.ibm.com`
3384+
Whereas the IBM Cloud Private VPC service for US South
3385+
(Dallas) could be configured with the service `name` of
3386+
`VPC` and `url` of `https://us.south.private.iaas.cloud.ibm.com`'
3387+
enum:
3388+
- CIS
3389+
- COS
3390+
- DNSServices
3391+
- GlobalSearch
3392+
- GlobalTagging
3393+
- HyperProtect
3394+
- IAM
3395+
- KeyProtect
3396+
- ResourceController
3397+
- ResourceManager
3398+
- VPC
3399+
type: string
3400+
url:
3401+
description: url is fully qualified URI with scheme https,
3402+
that overrides the default generated endpoint for a client.
3403+
This must be provided and cannot be empty.
3404+
type: string
3405+
required:
3406+
- name
3407+
- url
3408+
type: object
3409+
type: array
33673410
vpcName:
33683411
description: VPCName is the name of an already existing VPC to
33693412
be used during cluster creation.

pkg/asset/cluster/ibmcloud/ibmcloud.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010
)
1111

1212
// Metadata converts an install configuration to IBM Cloud metadata.
13-
func Metadata(infraID string, config *types.InstallConfig, meta *icibmcloud.Metadata) *ibmcloud.Metadata {
13+
func Metadata(infraID string, config *types.InstallConfig) *ibmcloud.Metadata {
14+
meta := icibmcloud.NewMetadata(config)
1415
accountID, _ := meta.AccountID(context.TODO())
1516
cisCrn, _ := meta.CISInstanceCRN(context.TODO())
1617
dnsInstance, _ := meta.DNSInstance(context.TODO())
@@ -40,6 +41,7 @@ func Metadata(infraID string, config *types.InstallConfig, meta *icibmcloud.Meta
4041
DNSInstanceID: dnsInstanceID,
4142
Region: config.Platform.IBMCloud.Region,
4243
ResourceGroupName: config.Platform.IBMCloud.ClusterResourceGroupName(infraID),
44+
ServiceEndpoints: config.Platform.IBMCloud.ServiceEndpoints,
4345
Subnets: subnets,
4446
VPC: config.Platform.IBMCloud.GetVPCName(),
4547
}

0 commit comments

Comments
 (0)