Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Provisioning ability for IBM Cloud Self-managed #1335

Merged
merged 22 commits into from
Apr 8, 2024
Merged
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
1 change: 1 addition & 0 deletions ods_ci/infrastructure_configuration.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ infrastructure_configurations:
provider: GCP
hive_cluster_name: rhodsawstest
hive_claim_name: rhodsawstestclaim
use_cluster_pool: True

77 changes: 77 additions & 0 deletions ods_ci/tasks/Resources/Provisioning/Hive/IBM/ibmcloud-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: Secret
metadata:
name: ibmcloud-sno-install-config
namespace: ${infrastructure_configurations}[hive_claim_ns]
type: Opaque
stringData:
install-config.yaml: |
apiVersion: v1
baseDomain: ${infrastructure_configurations}[base_domain]
credentialsMode: Manual
compute:
- name: worker
platform:
ibmcloud:
type: ${infrastructure_configurations}[worker_node_instance_type]
replicas: ${infrastructure_configurations}[worker_node_replicas]
controlPlane:
name: master
platform:
ibmcloud:
type: ${infrastructure_configurations}[master_node_instance_type]
replicas: ${infrastructure_configurations}[master_node_replicas]
metadata:
name: ${infrastructure_configurations}[hive_cluster_name]
networking:
clusterNetwork:
- cidr: 10.128.0.0/14
hostPrefix: 23
machineNetwork:
- cidr: 10.0.0.0/16
serviceNetwork:
- 172.30.0.0/16
fips: ${infrastructure_configurations}[fips_validation]
platform:
ibmcloud:
region: ${infrastructure_configurations}[ibmcloud_region]
pullSecret: '${infrastructure_configurations}[pull_secret]'
sshKey: ${infrastructure_configurations}[ssh_key]
- apiVersion: hive.openshift.io/v1
kind: ClusterImageSet
metadata:
name: ${infrastructure_configurations}[image_set]
namespace: ${infrastructure_configurations}[hive_claim_ns]
spec:
releaseImage: ${infrastructure_configurations}[release_image]
- apiVersion: v1
kind: Secret
metadata:
name: ibmcloud-creds
namespace: ${infrastructure_configurations}[hive_claim_ns]
type: Opaque
stringData:
ibmcloud_api_key: ${infrastructure_configurations}[ibmcloud_api_key]
- apiVersion: hive.openshift.io/v1
kind: ClusterDeployment
metadata:
name: ${infrastructure_configurations}[hive_cluster_name]
namespace: ${infrastructure_configurations}[hive_claim_ns]
spec:
baseDomain: ${infrastructure_configurations}[base_domain]
clusterName: ${infrastructure_configurations}[hive_cluster_name]
platform:
ibmcloud:
region: ${infrastructure_configurations}[ibmcloud_region]
credentialsSecretRef:
name: ibmcloud-creds
provisioning:
imageSetRef:
name: ${infrastructure_configurations}[image_set]
installConfigSecretRef:
name: ibmcloud-sno-install-config
manifestsSecretRef:
name: ${infrastructure_configurations}[hive_cluster_name]-manifests
56 changes: 45 additions & 11 deletions ods_ci/tasks/Resources/Provisioning/Hive/deprovision.robot
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
*** Settings ***
Documentation Set of keywords to handle self-managed cluster deprovisioning
Library OperatingSystem
Library OpenShiftLibrary


*** Keywords ***
Set Hive Default Variables
${cluster_name} = Get Variable Value ${cluster_name} %{TEST_CLUSTER}
Expand All @@ -12,27 +18,55 @@
Set Suite Variable ${hive_namespace}

Delete Cluster Configuration
Log Deleting cluster ${cluster_name} configuration console=True
@{Delete_Cluster} = Oc Delete kind=ClusterPool name=${pool_name}
... namespace=${hive_namespace} api_version=hive.openshift.io/v1
Log Many @{Delete_Cluster}
${Delete_Cluster} = Oc Delete kind=ClusterDeploymentCustomization name=${conf_name}
... namespace=${hive_namespace} api_version=hive.openshift.io/v1
Log Many @{Delete_Cluster}
IF ${use_cluster_pool}
Log Deleting cluster ${cluster_name} configuration console=True
@{Delete_Cluster} = Oc Delete kind=ClusterPool name=${pool_name}
... namespace=${hive_namespace} api_version=hive.openshift.io/v1
Log Many @{Delete_Cluster}
${Delete_Cluster} = Oc Delete kind=ClusterDeploymentCustomization name=${conf_name}
... namespace=${hive_namespace} api_version=hive.openshift.io/v1
Log Many @{Delete_Cluster}
ELSE
bdattoma marked this conversation as resolved.
Show resolved Hide resolved
${Delete_Cluster} = Oc Delete kind=ClusterDeployment name=${cluster_name}
... namespace=${hive_namespace} api_version=hive.openshift.io/v1
${rc} ${out} = Run And Return Rc And Output oc wait --for=delete cd/${cluster_name} --timeout 600s
Should Be Equal As Integers ${rc} ${0} ${out}
IF "${provider_type}" == "IBM"
Oc Delete kind=Secret name=${cluster_name}-manifests namespace=${hive_namespace}
${rc} ${srv_ids} = Run And Return Rc And Output
... ibmcloud iam service-ids --output json | jq -c '.[] | select(.name | contains("${cluster_name}-openshift-")) | .name' | tr -d '"' # robocop: disable:line-too-long
Should Be Equal As Integers ${rc} ${0} msg=${srv_ids}
${srv_ids} = Split To Lines ${srv_ids}
FOR ${index} ${srv} IN ENUMERATE @{srv_ids}
Log ${index}: ${srv}
${rc} ${out} = Run And Return Rc And Output ibmcloud iam service-id-delete ${srv} -f
Should Be Equal As Integers ${rc} ${0} msg=${out}
END
IF len($srv_ids) == 0
Log message=no Service IDs found on IBM Cloud corresponding to ${cluster_name} cluster. Please check.
... level=WARN
END
END
END

Deprovision Cluster
${cluster_claim} = Run Keyword And Return Status
... Unclaim Cluster ${claim_name}
IF ${use_cluster_pool}
${cluster_claim} = Run Keyword And Return Status
... Unclaim Cluster ${claim_name}
ELSE
${cluster_claim} = Set Variable ${FALSE}
END
${cluster_deprovision} = Run Keyword And Return Status
... Delete Cluster Configuration
IF ${cluster_claim} == False
IF ${use_cluster_pool} == True and ${cluster_claim} == False

Check notice

Code scanning / Robocop

'{{ block_name }}' condition can be simplified Note

'INLINE IF' condition can be simplified
... Log Cluster Claim ${claim_name} does not exists. Deleting Configuration console=True
IF ${cluster_deprovision} == False
... Log Cluster ${cluster_name} has not been deleted. Please do it manually console=True
... level=ERROR
Log Cluster ${cluster_name} has been deprovisioned console=True

Unclaim Cluster
[Arguments] ${unclaimname}
Oc Delete kind=ClusterClaim name=${unclaimname} namespace=${hive_namespace}
${status} = Oc Get kind=ClusterClaim name=${unclaimname} namespace=${hive_namespace}
Log ${status} console=True
Log ${status} console=True
Loading
Loading