Creating a Watson Discovery service instance from the command line

Use the command-line interface to create a Watson Discovery service instance.

This task is equivalent to provisioning a service instance from the Cloud Pak for Data web client. For more information, see Creating a Watson Discovery service instance from the web client. Alternatively, you can use the application programming interface to create a service instance. For more information, see Creating a Watson Discovery service instance programmatically.

Required role: To use the create command, you must have the can_provision permission in Cloud Pak for Data.

Prerequisite steps

Before you can use the Cloud Pak for Data command-line interface (cpd-cli) to create a service instance, you must complete the following steps:
  1. Install the cpd-cli. For more information, see Installing the Cloud Pak for Data command-line interface ().
  2. Create a Cloud Pak for Data configuration profile name that has permission to provision instances. For more information, see Creating a profile to use the management commands.

Creating the service instance

To create a service instance by using the command-line interface, complete the steps described in service-instance.create.

The following procedure describes the steps for creating a Watson Discovery service instance in more detail.
  1. Create a JSON file that defines the service instance that you want to create. Store the file in a location from which it can be referenced when you submit a command to the cpd-cli later.

    Use the following JSON snippet as a starting point, and then replace the values that are identified as variables.

    {
    	"addon_type": "discovery",
    	"addon_version": "${VERSION}",
    	"create_arguments": {
    		"deployment_id": "${PROJECT_CPD_INSTANCE}-wd",
    		"parameters": {
    			"serviceId": "discovery",
    			"url": "https://wd-discovery-gateway.${PROJECT_CPD_INSTANCE}.svc.cluster.local:60443/v2/service_instances",
    			"watson": true
    		}
    	},
    	"display_name": "<instance-name>",
    	"namespace": "${PROJECT_CPD_INSTANCE}"
    }
    Replace the following variables with values that reflect your deployment:
    ${VERSION}
    Environment variable for the version of the Cloud Pak for Data software that is installed.
    ${PROJECT_CPD_INSTANCE}
    Environment variable for the project name (formerly namespace) that was defined before the service was installed. For more information, see Setting up installation environment variables.
    <instance-name>
    Name that you want to use for the service instance. This name is displayed in the Instances page of the Cloud Pak for Data web client. The name can contain alphanumeric characters, spaces, dashes, underscores, and periods.
  2. Use the following command to create the service instance:
    cpd-cli service-instance create \
    --profile <cpd-configuration-profile-name> --from-source <filename.json>
    Specify values for the following parameters:
    <cpd-configuration-profile-name>
    Specify the Cloud Pak for Data configuration profile that you created as a prerequisite step. For example, cpd-admin-profile.
    <filename.json>
    Specify the file path to the JSON file that you created in the previous step.
For example:
cpd-cli service-instance create \
--profile cpd-admin-profile --from-source ./wd-instance.json

Listing the service instances

The following example syntax lists the Cloud Pak for Data service instances that are associated with the specified profile:

cpd-cli service-instance \
--profile <cpd-configuration-profile-name> list
For example:
cpd-cli service-instance \
--profile cpd-admin-profile list

Getting a service instance

The following example syntax returns information about the Cloud Pak for Data service instance that you specify by name.

cpd-cli service-instance \
--profile <cpd-configuration-profile-name> get <instance-name>
For example:
cpd-cli service-instance \
--profile cpd-admin-profile get wd-test-instance

Deleting a service instance

The following example syntax shows you how to delete a service instance that you specify by name:

cpd-cli service-instance \
--profile <cpd-configuration-profile-name> delete <instance-name>
For example:
cpd-cli service-instance \
--profile cpd-admin-profile delete wd-test-instance