Creating a service instance for Cognos Analytics programmatically
After you install Cognos Analytics, you must create at least one
Cognos Analytics service instance. Each service instance must be in a different Red Hat®
OpenShift® Container Platform project. You can create a service instance in
the operands project or in a project that is tethered to the operands
project. If you are a Cloud Pak for Data user, you can use the
/v3/service_instances
REST API call to programmatically create service
instances.
- Who needs to complete this task?
- To create a service instance programmatically by using the
/v3/service_instances
REST API call, you must have the Create service instances (can_provision
) permission in Cloud Pak for Data.
- When do you need to complete this task?
- Complete this task only if you want to create a service instance programmatically by using the
/v3/service_instances
REST API call.
Alternative methods for creating a service instance
- From the web client. For more information, see Creating a service instance for Cognos Analytics from the web client.
- By using the
cpd-cli service-instance create
command. For more information, see Creating a service instance for Cognos Analytics with the cpd-cli service-instance create command.
Information you need to complete this task
Review the following information before you create a service instance for Cognos Analytics:
- Version requirements
-
All of the components that are associated with an instance of Cloud Pak for Data must be installed or created at the same release. For example, if Cognos Analytics is installed at Version 5.0.3, you must create the service instance at Version 5.0.3.
Important: Cognos Analytics uses a different version number from Cloud Pak for Data. This topic includes a table that shows the Cognos Analytics version for each refresh of Cloud Pak for Data. Use this table to find the correct version based on the version of Cloud Pak for Data that is installed.
- Environment variables
-
The commands in this task use environment variables so that you can run the commands exactly as written.
- If you don't have the script that defines the environment variables, see Setting up installation environment variables.
- To use the environment variables from the script, you must source the environment variables
before you run the commands in this task. For example,
run:
source ./cpd_vars.sh
Before you begin
This task assumes that the following prerequisites are met:
Prerequisite | Where to find more information |
---|---|
Cognos Analytics is installed. | If this task is not complete, see Installing Cognos Analytics. |
The cpd-cli command-line interface is installed on the
workstation from which you will create the service instance. |
If this task is not complete, see Setting up a client workstation. |
You generated an API key or authorization token The API key or token must be associated
with a user who has the Create service instances
( |
If this task is not complete, see Generating an authorization token or API key. |
The content store is configured. You can also use the content store for your audit
content. Important: When you provision your instance, you must use the same IAM mode as
your content store.
|
If this task is not complete, see Configuring the content store for Cognos Analytics. |
You must have sufficient resources for the plan size that you select. If you do not have sufficient resources, the instance cannot be created.
Plan size | Minimum required resources | Maximum required resources | Largest pod |
---|---|---|---|
Fixed Minimum | Across the cluster, you must have at least:
|
At most, the instance uses:
|
The largest pod requires up to:
|
XSmall | Across the cluster, you must have at least:
|
At most, the instance uses:
|
The largest pod requires up to:
|
Small or Small with minimal reserved CPU resources | Across the cluster, you must have at least:
|
At most, the instance uses:
|
The largest pod requires up to:
|
Medium | Across the cluster, you must have at least:
|
At most, the instance uses:
|
The largest pod requires up to:
|
Large | Across the cluster, you must have at least:
|
At most, the instance uses:
|
The largest pod requires up to:
|
Procedure
Complete the following tasks to create a service instance:
Creating a service instance
To create a service instance:
- Change to the directory on your workstation where you want to create the JSON file that defines the service instance payload.
- Set the environment variables that are used to populate the JSON payload
for the service instance:
- Set the
INSTANCE_NAME
environment variable to the unique name that you want to use as the display name for the service instance:export INSTANCE_NAME="<display-name>"
This name is displayed on the Instances page of the Cloud Pak for Data web client.
The display name is a
string
and can contain alphanumeric characters (a-z, A-Z, 0-9), spaces ( ), dashes (-), underscores (_), and periods (.). Make sure that you surround the display name with quotation marks, as shown in the precedingexport
command. - Set the
INSTANCE_VERSION
environment variable to the version that corresponds to the version of Cloud Pak for Data on your cluster:export INSTANCE_VERSION=<version>
Use the following table to determine the appropriate value:
Cloud Pak for Data version Service instance version 5.0.3 26.3.0 5.0.2 26.2.0 5.0.1 26.1.0 5.0.0 26.0.0 - Set the
INSTANCE_PROJECT
to the project where you want to create the service instance:
Create the service instance in the operands project
export INSTANCE_PROJECT=${PROJECT_CPD_INST_OPERANDS}
The command uses the
PROJECT_CPD_INST_OPERANDS
variable, which is already defined in your installation environment variables script.
Create the service instance in a tethered project
Important: If multiple tethered projects are associated with this instance of Cloud Pak for Data, make sure that the${PROJECT_CPD_INSTANCE_TETHERED}
environment variable is set to the correct project name before you run theexport
command:echo $PROJECT_CPD_INSTANCE_TETHERED
export INSTANCE_PROJECT=${PROJECT_CPD_INSTANCE_TETHERED}
Remember: You can create only one service instance in each project. - Set the
CPD_ROUTE
environment variable:export CPD_ROUTE=$(oc get route cpd -n ${PROJECT_CPD_INST_OPERANDS} -o jsonpath={".spec.host"})
The command uses the
PROJECT_CPD_INST_OPERANDS
variable, which is already defined in your installation environment variables script. - Set the
CONTENT_STORE_CONNECTION_NAME
environment variable to the name of the platform connection that you created to connect to the content store for the service instance.export CONTENT_STORE_CONNECTION_NAME=<connection-display-name>
- Set the
AUDIT_DB_CONNECTION_NAME
environment variable to the name of the platform connection that you created to connect to the audit database for the service instance.export AUDIT_DB_CONNECTION_NAME=<connection-display-name>
- Set the
INSTANCE_SIZE
environment variable. The size determines the resources that are allocated to the service instance.export INSTANCE_SIZE=<size>
Valid values are:small_mincpureq
fixedminimum
xsmall
small
medium
large
For more information about the resources associated with each size, see the component scaling guidance PDF, which you can download from the IBM Entitled Registry.
- Set the
FIPS_MODE
andFIPS_MODE_LABEL
environment variables based on whether FIPS is enabled on the cluster:- If FIPS is not enabled on the cluster,
set:
export FIPS_MODE="" export FIPS_MODE_LABEL=""
- If FIPS is enabled on the cluster,
set:
export FIPS_MODE=FIPS_140 export FIPS_MODE_LABEL="FIPS 140-2"
- If FIPS is not enabled on the cluster,
set:
- Set the
- Create the
cognos-analytics-instance.json
payload file:cat << EOF > ./
cognos-analytics-instance.json
{ "addon_type": "cognos-analytics-app", "display_name": "${INSTANCE_NAME}", "addon_version": "${INSTANCE_VERSION}", "namespace": "${INSTANCE_PROJECT}", "create_arguments": { "deployment_id": "", "parameters": { "global.cp4dWebUrlBase": "https://${CPD_ROUTE}", "global.icp4Data": "true", "global.tls.enabled": "false", "global.icp4DataVersion": "${INSTANCE_VERSION}", "global.cs.databaseExternal": "true", "global.cs.databaseConnectionName": "${CONTENT_STORE_CONNECTION_NAME}", "global.audit.databaseExternal": "true", "global.audit.databaseConnectionName": "${AUDIT_DB_CONNECTION_NAME
}", "pvc.pvProvisioning": "NamedStorageClass", "pvc.storageClassName": "${STG_CLASS_FILE}", "pvc.blockStorageClassName": "${STG_CLASS_BLOCK}", "metadata.planSize": "${INSTANCE_SIZE}", "metadata.storageType": "storage-class", "metadata.storageClass": "${STG_CLASS_FILE}", "metadata.cryptoConformanceLabel": "${FIPS_MODE_LABEL}", "metadata.cryptoConformance": "${FIPS_MODE}", "metadata.autoScaleConfig": "true" } } } EOFThe following environment variables use the values that are already defined in your installation environment variables script:${STG_CLASS_BLOCK}
${STG_CLASS_FILE}
- Set the
PAYLOAD_FILE
environment variable to the fully qualified name of the JSON payload file on your workstation:export PAYLOAD_FILE=<fully-qualified-JSON-file-name>
- Set the environment variables that are used to connect to the
instance of Cloud Pak for Data where you want to create the service
instance:
- Set the
API_KEY
environment variable to the API key that you created:export API_KEY=<your_api_key>
- Set the
- Create the service instance from the payload file.
The command that you run depends on whether the instance of Cloud Pak for Data where you want to create the service instance uses a self-signed certificate or a certificate signed by a trusted certificate authority.
The instance uses a certificate signed by a trusted certificate authority
curl --request POST \ --url "https://${CPD_ROUTE}/zen-data/v3/service_instances" \ --header "Authorization: ZenApiKey ${API_KEY}" \ --header 'Content-Type: application/json' \ --data @${PAYLOAD_FILE}
The instance uses a self-signed certificate (default)
curl -k --request POST \ --url "https://${CPD_ROUTE}/zen-data/v3/service_instances" \ --header "Authorization: ZenApiKey ${API_KEY}" \ --header 'Content-Type: application/json' \ --data @${PAYLOAD_FILE}
If the request was successful, the command returns one of the following HTTP response codes:- 200 - The request was successfully completed and the service instance was provisioned.
- 202 - The request was successfully submitted. The service instance is being provisioned.
If the request was not successful, use the HTTP response code to determine the reason.
Validating that the service instance was created
To validate that the service instance was created:
- Set the
INSTANCE_ID
environment variable to the ID that was returned by thePOST
cURL command:export INSTANCE_ID=<ID-from-response>
- Run the following command to get the status of the service instance:
curl --request GET \ --url "https://${CPD_ROUTE}/zen-data/v3/service_instances/${INSTANCE_ID}" \ --header "Authorization: ZenApiKey ${AUTH_TOKEN}" \ --header 'Content-Type: application/json'
- If the request was successful, the command returns the following HTTP response code:
200Find the
provision_status
parameter in the JSON response.- If the value is
RUNNING
, the service instance was successfully created. - If the value is
PROVISION_IN_PROGRESS
, wait a few minutes and run the command again. - If the value is
FAILED
, review the pod logs for theibm-cognos-addon-sp-deployment-*
,ibm-ca-operator-controller-manager-*
,zen-core-api
, andzen-watcher
pods for possible causes.
- If the value is
- If the request was not successful, use the HTTP response code to determine the reason.
- If the request was successful, the command returns the following HTTP response code:
200