Managing Cloud Pak for Data service instances by command line

The cpd-cli service-instance command line interface can manage Cloud Pak for Data service instances.

What permissions do you need to complete this task?
The service-instance command requires cluster administrator or similar roles.
When do you need to complete this task?
Note: The following examples use the recommended installation environment variables.

Use a script to create environment variables with the correct values for your environment. For more information, see Best practice: Setting up install variables.

Creating service instances

The following example creates a service instance in your Cloud Pak for Data instance.

cpd-cli service-instance create \
--profile=${CPD_PROFILE_NAME} \
--from-source=<json-template>

For --from-source, you can specify a JSON template path and file name. The JSON template file is used to create the service instance.

Note: The JSON file can store information about different contexts, where each context can refer to a different service environment. If your service uses the cpd-cli to manage service instances, refer to your specific service documentation for JSON template configuration information.

Retrieving service instance information

The following example lists all of the service instances in your Cloud Pak for Data instance.

cpd-cli service-instance list \
--profile=${CPD_PROFILE_NAME} \
--output=json|yaml|text

For the output type, you can specify json, text, or yaml. The default output type is text.

Example of the service instance list:
 Namespace           Service type        Version             ID                  Name                  Provision status    Upgrade version option 
 ---------           ------------        -------             --                  ----                  ----------------    ---------------------- 
 CPD_PROFILE_NAME        volumes             -                   1600820045121846    vol1                  PROVISIONED         [] 
 CPD_PROFILE_NAME        dv                  2.0.2.0             1600736770511387    watson-query          PROVISIONED         [] 

The following example retrieves status on a specific service instance.

cpd-cli service-instance status <cpd-service-instance-name> \
--profile=${CPD_PROFILE_NAME} \
--output=json|yaml|text

For the output type, you can specify json, text, or yaml. The default output type is text.

Example of the service instance status:
 Namespace           Service type        Version             ID                  Name                  Provision status    Service status 
 ---------           ------------        -------             --                  ----                  ----------------    -------------- 
 CPD_PROFILE_NAME        dv                  2.0.2.0             1600736770511387    watson-query          PROVISIONED         RUNNING

The following example retrieves details on a specific service instance.

cpd-cli service-instance get <cpd-service-instance-name> \
--profile=${CPD_PROFILE_NAME} \
--output=json|yaml|text

For the output type, you can specify json or yaml. The default output type is json.

Example of a service instance JSON file:
{
  "service_instance": {
    "addon_type": "dv",
    "addon_version": "2.0.2.0",
    "connection_info": {
      "jdbc": "jdbc:db2://dv-server.default.svc.cluster.local:32051/bigsql"
    },
    "created_at": "2023-01-22T01:06:28.432179Z",
    "description": "Watson Query",
    "display_name": "watson-query",
    "id": "1600736770511387",
    "instance_identifiers": [
      "dv-0-1600736770511387",
      "dv-1-1600736770511387",
      "dv-2-1600736770511387",
      "dv-3-1600736770511387"
    ],
    "metadata": {},
    "misc_data": {},
    "namespace": "${CPD_PROFILE_NAME}",
    "owner_uid": "1000000999",
    "owner_username": "user123",
    "parameters": {
      "enableHostIPC": "true",
      "image.pullPolicy": "IfNotPresent",
      "persistence.cachingpv.size": "100Gi",
      "persistence.cachingpv.storageClass": "managed-nfs-storage",
      "persistence.size": "50Gi",
      "persistence.storageClass": "managed-nfs-storage",
      "persistence.workerpv.size": "25Gi",
      "persistence.workerpv.storageClass": "managed-nfs-storage",
      "resources.dv.requests.cpu": "4",
      "resources.dv.requests.memory": "16Gi",
      "workerCount": "1"
    },
    "provision_status": "PROVISIONED",
    "resources": {
      "cpu": "4",
      "memory": "16"
    },
    "roles": [
      "Admin"
    ],
    "updated_at": "2023-1-07T00:51:51.842894Z",
    "zen_service_instance_info": {
      "docker_registry_prefix": "image-registry.openshift-image-registry.svc:5000/profile"
    }
  }
}

The following example retrieves details on all service instances of the same service type.

cpd-cli service-instance get \
--service-type=<cpd-service-name> \
--all \
--profile=${CPD_PROFILE_NAME} \
--output=json|yaml|text \
--output-dir=<output-directory>

For the output type, you can specify json or yaml. The default output type is json.

Upgrading service instances

The following example upgrades a specific service instance in your Cloud Pak for Data instance.

cpd-cli service-instance upgrade \
--instance-name=<cpd-service-instance-name> \
--service-type=<cpd-service-name> \
--profile=${CPD_PROFILE_NAME}

Append --version if you need to upgrade to a specific version. Append --watch to continuously monitor the upgrade progress.

The following example upgrades all service instances of the same service type.

cpd-cli service-instance upgrade \
--service-type=<cpd-service-name> \
--all \
--profile=${CPD_PROFILE_NAME}

Append --watch to continuously monitor the upgrade progress.

Note: If your service uses the cpd-cli to manage service instances, refer to your specific service documentation for upgrade information.

Deleting service instances

The following example deletes a specific service instance.

cpd-cli service-instance delete <cpd-service-instance-name> \
--service-type=<cpd-service-name> \
--profile=${CPD_PROFILE_NAME}

The command submits a request to deprovision the service instance. Use the cpd-cli service-instance status command to monitor the status.