Skip to content

Commit 7a9f899

Browse files
authored
feat: add support for deploying ocp using custom cloud endpoints. (#578)
1 parent 8b61be0 commit 7a9f899

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ module "ocp_base" {
117117
}
118118
```
119119

120+
### Customizing default cloud service endpoints.
121+
122+
The user must export the endpoint as an environment variable in order to use custom cloud service endpoints with this module. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints#1-define-service-endpoints-by-using-environment-variables).
123+
124+
**Important** The only supported method for customizing cloud service endpoints is to export the endpoint; be sure to export the value for `IBMCLOUD_API_ENDPOINT`. For example,
125+
```
126+
export IBMCLOUD_API_ENDPOINT="<endpoint_url>"
127+
```
128+
120129
### Secure by default cluster settings
121130

122131
In OCP version 4.15, outbound traffic is disabled by default. [Learn more](https://cloud.ibm.com/docs/openshift?topic=openshift-vpc-security-group-reference).

scripts/confirm_lb_active.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,25 @@ set -euo pipefail
55
REGION="$1"
66
LB_ID="$2"
77
PRIVATE_ENV="$3"
8+
CLOUD_ENDPOINT=""
89
API_VERSION="2024-03-01"
910

1011
if [[ -z "${REGION}" ]]; then
1112
echo "Region must be passed as first input script argument" >&2
1213
exit 1
1314
fi
1415

16+
get_cloud_endpoint() {
17+
cloud_endpoint="${IBMCLOUD_API_ENDPOINT:-"cloud.ibm.com"}"
18+
CLOUD_ENDPOINT=${cloud_endpoint#https://}
19+
}
20+
21+
get_cloud_endpoint
1522
lb_attempts=1
1623
if [ "$PRIVATE_ENV" = true ]; then
17-
URL="https://$REGION.private.iaas.cloud.ibm.com/v1/load_balancers/$LB_ID?version=$API_VERSION&generation=2"
24+
URL="https://$REGION.private.iaas.$CLOUD_ENDPOINT/v1/load_balancers/$LB_ID?version=$API_VERSION&generation=2"
1825
else
19-
URL="https://$REGION.iaas.cloud.ibm.com/v1/load_balancers/$LB_ID?version=$API_VERSION&generation=2"
26+
URL="https://$REGION.iaas.$CLOUD_ENDPOINT/v1/load_balancers/$LB_ID?version=$API_VERSION&generation=2"
2027
fi
2128

2229
while true; do

scripts/reset_iks_api_key.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RESOURCE_GROUP_ID="$2"
77
APIKEY_KEY_NAME="containers-kubernetes-key"
88
PRIVATE_ENV="$3"
99
CLUSTER_ENDPOINT="$4"
10+
CLOUD_ENDPOINT=""
1011

1112
if [[ -z "${REGION}" ]]; then
1213
echo "Region must be passed as first input script argument" >&2
@@ -18,10 +19,17 @@ if [[ -z "${RESOURCE_GROUP_ID}" ]]; then
1819
exit 1
1920
fi
2021

22+
get_cloud_endpoint() {
23+
cloud_endpoint="${IBMCLOUD_API_ENDPOINT:-"cloud.ibm.com"}"
24+
CLOUD_ENDPOINT=${cloud_endpoint#https://}
25+
}
26+
27+
get_cloud_endpoint
28+
2129
if [ "$PRIVATE_ENV" = true ]; then
22-
IAM_URL="https://private.iam.cloud.ibm.com/v1/apikeys?account_id=$ACCOUNT_ID&scope=account&pagesize=100&type=user&sort=name"
30+
IAM_URL="https://private.iam.$CLOUD_ENDPOINT/v1/apikeys?account_id=$ACCOUNT_ID&scope=account&pagesize=100&type=user&sort=name"
2331
else
24-
IAM_URL="https://iam.cloud.ibm.com/v1/apikeys?account_id=$ACCOUNT_ID&scope=account&pagesize=100&type=user&sort=name"
32+
IAM_URL="https://iam.$CLOUD_ENDPOINT/v1/apikeys?account_id=$ACCOUNT_ID&scope=account&pagesize=100&type=user&sort=name"
2533
fi
2634

2735
reset=true
@@ -53,16 +61,16 @@ fetch_data
5361
if [ "${reset}" == true ]; then
5462
if [ "$PRIVATE_ENV" = true ]; then
5563
if [ "$CLUSTER_ENDPOINT" == "private" ] || [ "$CLUSTER_ENDPOINT" == "default" ]; then
56-
RESET_URL="https://private.$REGION.containers.cloud.ibm.com/v1/keys"
64+
RESET_URL="https://private.$REGION.containers.$CLOUD_ENDPOINT/v1/keys"
5765
result=$(curl -i -H "accept: application/json" -H "Authorization: $IAM_TOKEN" -H "X-Auth-Resource-Group: $RESOURCE_GROUP_ID" -X POST "$RESET_URL" 2>/dev/null)
5866
status_code=$(echo "$result" | head -n 1 | cut -d$' ' -f2)
5967
elif [ "$CLUSTER_ENDPOINT" == "vpe" ]; then
60-
RESET_URL="https://api.$REGION.containers.cloud.ibm.com/v1/keys"
68+
RESET_URL="https://api.$REGION.containers.$CLOUD_ENDPOINT/v1/keys"
6169
result=$(curl -i -H "accept: application/json" -H "Authorization: $IAM_TOKEN" -H "X-Auth-Resource-Group: $RESOURCE_GROUP_ID" -X POST "$RESET_URL" 2>/dev/null)
6270
status_code=$(echo "$result" | head -n 1 | cut -d$' ' -f2)
6371
fi
6472
else
65-
RESET_URL="https://containers.cloud.ibm.com/global/v1/keys"
73+
RESET_URL="https://containers.$CLOUD_ENDPOINT/global/v1/keys"
6674
result=$(curl -i -H "accept: application/json" -H "X-Region: $REGION" -H "Authorization: $IAM_TOKEN" -H "X-Auth-Resource-Group: $RESOURCE_GROUP_ID" -X POST "$RESET_URL" -d '' 2>/dev/null)
6775
status_code=$(echo "$result" | head -n 1 | cut -d$' ' -f2)
6876
fi

0 commit comments

Comments
 (0)