Introduction
The Cloud Pak for Data Instance Management API allows users to set up and manage an instance of Cloud Pak for Data.
You can perform the following tasks by using this API:
- Install and upgrade an instance of Cloud Pak for Data
- A cluster admin can install and upgrade an instance of Cloud Pak for Data.
- Shut down and restart an instance of Cloud Pak for Data
- A cluster admin can shut down and restart installed components in an instance of Cloud Pak for Data.
- Get the status of an instance of Cloud Pak for Data
- A cluster admin can get the status of installed components in an instance of Cloud Pak for Data.
Authentication
To authenticate to the API, pass an access token in an Authorization
header.
Generating a Red Hat OpenShift access token through the Red Hat OpenShift console:
- Log in to the Red Hat OpenShift web console.
- Click your profile.
- Click Copy Login Command.
- Click Display Token.
- Copy and save your API token.
Generate a Red Hat OpenShift access token by using the command-line interface.
- Log in to the Red Hat OpenShift cluster and get the host.
host=$(oc get route -n openshift-authentication oauth-openshift -o jsonpath='{.spec.host}')
- Get the access token for the user.
Replace
{openshift_username}
and{openshift_password}
with your Red Hat OpenShift credentials. Replace{host}
with the result that you got from previous step.
curl -u {openshift_username}:{openshift_password} -kv '{host}/oauth/authorize?client_id=openshift-challenging-client&response_type=token'
- Copy and save the API token.
Authenticating to the API by using an access token. Replace {token}
with your details.
- Get the cpd-mgmt-api-host
cpd-mgmt
from the server namespace. - Call a method, replacing the
{cpd-mgmt-api-host}
with the result that you got from previous step.
curl -H "Authorization: Bearer {token}" "https://{cpd-mgmt-api-host}/v1/{method}"
Disabling SSL verification
All Cloud Pak for Data services use Secure Sockets Layer (SSL) or Transport Layer Security (TLS) for secure connections between the client and server. The connection is verified against the local certificate store to ensure authentication, integrity, and confidentiality.
If you use a self-signed certificate, you need to disable SSL verification to make a successful connection.
Enabling SSL verification is highly recommended. Disabling SSL jeopardizes the security of the connection and data. Disable SSL only if necessary, and take steps to enable SSL as soon as possible.
To disable SSL verification for a curl request, use the --insecure
(-k
) option with the request.
Example that disables SSL verification
curl -k -X {request_method} -H "Authorization: Bearer {token}" "{url}/v1/{method}"
Error handling
OLM-UTILS uses standard HTTP response codes to indicate whether a method was successful. HTTP response codes in the 2xx range indicate success. A response in the 4xx range is a failure, and a response in the 5xx range usually indicates an internal system error that cannot be resolved by the user. Response codes are listed with the method.
Methods
Configure shared cluster components
Install, upgrade, or configure the shared cluster components.
Prerequisite: To use this endpoint, you must install the management service on your cluster.
You can use one of the following methods to specify the settings that you want to use for the shared cluster components:
-
ConfigMap Use the
mgmt_cluster_configmap configmap
if you want to have a traceable history of changes to the shared cluster components.Important: To use this option, the
mgmt_cluster_configmap configmap
must exist in the project where the management service is installed. -
JSON: Use this option if you don't have sufficient privileges to create the
mgmt_cluster_configmap configmap
in the project where the management service is installed.
POST /v1/cluster/configs
Response
Status Code
Success. Nothing to be configured.
Accepted. A job will start in the background.
The
mgmt_cluster_configmap configmap
is missing or invalid.Unauthorized. The Red Hat OpenShift token is missing or invalid.
Forbidden. User does not have the required permissions to access the resource.
Internal server error.
No Sample Response
Get the status of the shared cluster components
Get information about the status and configuration of the shared cluster components.
Prerequisite: To use this method, you must install the management service on your cluster.
GET /v1/cluster
Request
Query Parameters
Specify whether to read the desired state for the cluster components from the
mgmt_cluster_configmap configmap
, which enables you to see the expected versions based on the release that is specified in the configmap compared to the actual versions running on the cluster.Default:
false
Response
The name of the component.
Status Code
Success. Returns a JSON representation that describes the current state of the shared cluster components.
Unauthorized. The Red Hat OpenShift token is missing or invalid.
Forbidden. User does not have the required permissions to access the resource.
Not found.
Internal server error.
No Sample Response
Configure an instance
Install, upgrade, or configure the components associated with an instance of Cloud Pak for Data by applying the contents of the specified configmap.
Important: You must be an instance administrator or cluster administrator to use this method.
- If you are an instance administrator, a cluster administrator must install the shared cluster components before you install an instance of Cloud Pak for Data.
- If you are a cluster administrator, the management service automatically installs the shared cluster
components if it can find the
mgmt_cluster_configmap configmap
.
POST /v1/instance/configs
Response
Status Code
Success. There are no changes to the instance.
Accepted. Started an asynchronous job to configure the instance.
Bad Request.
Unauthorized. The Red Hat OpenShift token is missing or invalid.
Forbidden. User does not have the required permissions to access the resource.
Internal server error.
No Sample Response
Get the status of an instance of Cloud Pak for Data
Get information about the status and configuration of the components associated with an instance of Cloud Pak for Data.
Prerequisite: To use this endpoint, you must install the management service on your cluster.
GET /v1/instance
Request
Query Parameters
The project where the operands for the instance are installed.
The project where the operators for the instance are installed.
The list of components to query. If not set, return everything.
Do not return error if one or more components are not found in the instance.
Default:
true
Response
- instance
A list of tethered namespaces associated with the instance of Cloud Pak for Data.
- components
The name of the component.
The addon ID used by the zen UI of the component.
This parameter is mutually exclusive with cr_list.
Status Code
Success. Returns a JSON representation that describes the current state of all the installed components or the components that are queried.
Bad Request. One of the request components does not found in the instance.
Unauthorized. The Red Hat OpenShift token is missing or invalid.
Forbidden. User does not have the required permissions to access the resource.
Internal server error.
No Sample Response
Shut down services installed in an instance of Cloud Pak for Data
This method shuts down one or more services that are installed in an instance of Cloud Pak for Data.
POST /v1/instance/shutdown
Response
Status Code
Success. Nothing to shut down.
Accepted. Return a job ID that is created by the server.
Bad Request. One of the request components is not valid.
Unauthorized. The Red Hat OpenShift token is missing or invalid.
Forbidden. User does not have the required permissions to access the resource.
Internal server error.
{ "job_id": "job_id", "logs": "logs", "status": "status" }
Restart services installed in an instance of Cloud Pak for Data
This method restarts one or more services and all of their dependencies that are installed on an instance of Cloud Pak for Data.
POST /v1/instance/restart
Response
Status Code
Success. Nothing to restart.
Accepted. Return a job ID that is created by the server.
Bad Request. One of the request components is not valid.
Unauthorized. The Red Hat OpenShift token is missing or invalid.
Forbidden. User does not have the required permissions to access the resource.
Internal server error.
{ "job_id": "job_id", "logs": "logs", "status": "status" }
Scale one or more Cloud Pak for Data services or components
This method scales one or more services that are installed on an instance of Cloud Pak for Data.
POST /v1/instance/scale
Response
Status Code
Success. Nothing to scale.
Accepted. Return a job ID that is created by the server.
Bad Request. One of the request components is not valid.
Unauthorized. The Red Hat OpenShift token is missing or invalid.
Forbidden. User does not have the required permissions to access the resource.
Internal server error.
{ "job_id": "job_id", "logs": "logs", "status": "status" }
Apply horizontal pod autoscaling (HPA) for one or more Cloud Pak for Data services or components
This method applies horizontal pod autoscaling (HPA) to one or more services that are installed on an instance of Cloud Pak for Data.
POST /v1/instance/hpa
Request
{
"namespace": "cpd-instance",
"components": [
"ws",
"wkc"
],
"hpa_enabled": true
}
Response
Status Code
Success. Nothing to scale.
Accepted. Return a job ID that is created by the server.
Bad Request. One of the request components is not valid.
Unauthorized. The Red Hat OpenShift token is missing or invalid.
Forbidden. User does not have the required permissions to access the resource.
Internal server error.
{ "job_id": "job_id", "logs": "logs", "status": "status" }
Get the list of jobs generated by the cpd-mgmt server
Display all jobs that are generated by the server and associated with the user. The search can be narrowed by operator namespace and instance namespace. Additionally, jobs that are related to cluster components are not displayed by default.
GET /v1/jobs
Query the metadata of Cloud Pak for Data components
Query the ansible-play config-var metadata from olm utils for information on a single component of a Cloud Pak for Data release.
GET /v1/metadata