Creating a profile to use the cpd-cli management commands

Before you can complete certain set up and management tasks for IBM Cloud Pak® for Data, you must create a profile so that you can run the appropriate cpd-cli commands.

About this task

Any user who plans to complete the following tasks needs to create a profile:
  • Gathering diagnostics and checking the health of the Cloud Pak for Data cluster (by running the cpd-cli diag command)
  • Managing Cloud Pak for Data users (by running the cpd-cli user-mgmt command)
  • Managing service instances (by running the cpd-cli service-instance command)
  • Migrating data, including metadata, between Cloud Pak for Data deployments (by running the cpd-cli export-import command)

Before you run any cpd-cli commands, ensure that:

A profile enables the cpd-cli to verify that you are a Cloud Pak for Data user and that you have the appropriate administrator permissions to complete a specific task.

Note: The following examples use environment variables. Use a script to create environment variables with the correct values for your environment. You can optionally add the listed environment variables to the install variables script. For more information, see Best practice: Setting up install variables.
export CPD_ADMIN_USER=<enter the Cloud Pak for Data user alias to be stored in the local cpd-cli configuration (for example, 'prod-cpd-admin')>
export CPD_PROFILE_NAME=<enter the Cloud Pak for Data cpd-cli profile name (for example, 'prod-cpd-profile')>
export CPD_PROFILE_URL=<enter the Cloud Pak for Data web URL. You must add https protocol to the URL that is returned by the 'oc get routes' command>

Procedure

  1. Generate the API key that you need for user authentication by going to your Profile and settings page in the Cloud Pak for Data client and clicking Generate API key.
    This API key does not expire. The configuration information is stored in $HOME/.cpd-cli/config.
  2. Create a local user configuration for yourself by pasting the API key in the following command:
    ./cpd-cli config users set ${CPD_ADMIN_USER} --username admin --apikey <api_key>

    where the ${CPD_ADMIN_USER} installation environment variable is defined as the Cloud Pak for Data user alias to be stored in the local cpd-cli configuration and <api_key> is replaced with the key that was generated in step 1.

    Anytime you regenerate the API key, you must rerun this command to update your local user configuration.

    Tip: To delete a user, you can enter the command:
    ./cpd-cli config users unset ${CPD_ADMIN_USER}
  3. Set a new profile to store the Cloud Pak for Data URL and its association with the local configuration you created:
    ./cpd-cli config profiles set ${CPD_PROFILE_NAME} --user ${CPD_ADMIN_USER} --url ${CPD_PROFILE_URL}

    where the ${CPD_PROFILE_NAME} environment variable is defined as the new Cloud Pak for Data cpd-cli profile name and the ${CPD_PROFILE_URL} environment variable is defined as the Cloud Pak for Data web URL.

    Important: You can determine the Cloud Pak for Data web URL by running the oc get routes command. You must add HTTPS protocol to the Cloud Pak for Data web URL (for example, https://<cpd-web-url>).

    If you have multiple Cloud Pak for Data instances, you must set a new profile on every instance. You can also have profiles for other users in the same Cloud Pak for Data user profile URL.

    Tip: To delete a profile, you can enter the command:
    ./cpd-cli config profiles unset ${CPD_PROFILE_NAME}

Results

You can now run cpd-cli commands with this profile by using the --profile flag. For example:

./cpd-cli service-instance list --profile ${CPD_PROFILE_NAME}

Otherwise, you receive an Error: required flag(s) "profile" not set error.