IBM / cloud-pak-deployer

Configuration-based installation of OpenShift and Cloud Pak for Data/Integration/Watson AIOps on various private and public cloud infrastructure providers. Deployment attempts to achieve the end-state defined in the configuration. If something fails along the way, you only need to restart the process to continue the deployment.
https://ibm.github.io/cloud-pak-deployer/
Apache License 2.0
130 stars 65 forks source link

DB2 is not correctly registered in DMC when deployed together #638

Closed gasgithub closed 2 months ago

gasgithub commented 4 months ago

Describe the bug When deploying Cp4d with DB2 and DMC enabled with params like these:

                  - name: db2
                    description: Db2 OLTP
                    size: $(params.db2-size)
                    instances:
                    - name: db2oltp-31313131
                      metadata_size_gb: 20
                      data_size_gb: 20
                      backup_size_gb: 20  
                      transactionlog_size_gb: 20
                    state: $(params.db2-state)

                  - name: dmc
                    description: Db2 Data Management Console
                    state: $(params.dmc-state)
                    instances:
                    - name: data-management-console                    

Both services (db2oltp and dmc) are installed, enabled, and instances are created, but dmc shows no instances of db2.

Instance can be manually added following this - https://www.ibm.com/docs/en/cloud-paks/cp-data/4.8.x?topic=console-adding-instance-db2-data-management-manually but it is very error prone and inconvenient.

Here is bash script that I used to fix that

#!/bin/bash
export CPD_ROUTE=$(oc get route cpd -n cpd -o jsonpath="{.spec.host}")

export CPD_ADMIN_PASSWORD=$(oc get secret "admin-user-details" -n cpd -o jsonpath="{.data.initial_admin_password}"| base64 -d)

export CPD_TOKEN=$(curl --location --request POST "https://$CPD_ROUTE/v1/preauth/signin" --header 'Content-Type: application/json' --data-raw "{\"username\":\"admin\",\"password\":\"$CPD_ADMIN_PASSWORD\"}" | jq -r .token)

# check dmc state
curl --location --request POST "https://$CPD_ROUTE/zen-data/v1/addOn/query" \
--header "Authorization: Bearer $CPD_TOKEN" \
--header 'Content-Type: application/json' \
--data-raw '{
    "type": "dmc"
}' | jq .requestObj[0].State

# get dmc id
export DMC_ID=$(curl --location --request GET "https://$CPD_ROUTE/zen-data/v3/service_instances?fetch_all_instances=true" --header "Authorization: Bearer $CPD_TOKEN"  | jq -r '.service_instances[] | select(.addon_type =="dmc").id')

# get db2oltp id
export DB2OLT_ID=$(curl --location --request GET "https://$CPD_ROUTE/zen-data/v3/service_instances?fetch_all_instances=true" --header "Authorization: Bearer $CPD_TOKEN"  | jq -r '.service_instances[] | select(.addon_type =="db2oltp").id')

# get db2oltp display name - OTHERWISE IT NOT WORKS!!!!
export DB2OLT_DISPLAY_NAME=$(curl --location --request GET "https://$CPD_ROUTE/zen-data/v3/service_instances?fetch_all_instances=true" --header "Authorization: Bearer $CPD_TOKEN"  | jq -r '.service_instances[] | select(.addon_type =="db2oltp").display_name')

# get the db2 password
export DB2_PASSWORD=$(oc get secret "c-db2oltp-$DB2OLT_ID-instancepassword" -n cpd -o jsonpath="{.data.password}"| base64 -d)

curl --location --request POST "https://$CPD_ROUTE/addon-dmc/v1/profiles" \
--header "Authorization: Bearer $CPD_TOKEN" \
--header 'Content-Type: application/json' \
--data-raw "{
  \"CollectionCred\": {
    \"password\": \"$DB2_PASSWORD\",
    \"securityMechanism\": \"9\",
    \"user\": \"db2inst1\"
  },
  \"databaseName\": \"BLUDB\",
  \"dbInstanceId\": \"$DB2OLT_ID\",
  \"dbType\": \"db2oltp\",
  \"display_name\": \"$DB2OLT_DISPLAY_NAME\",
  \"dmcInstanceId\": \"$DMC_ID\",
  \"host\": \"c-db2oltp-$DB2OLT_ID-db2u\",
  \"plan\": \"smp\",
  \"port\": 50001,
  \"sslCertLocation\": \"/opt/ibm-datasrvrmgr/Config/cpd-internal-tls/ca.crt\",
  \"sslConnection\": true
}"