Este conteúdo não está disponível no idioma selecionado.
Chapter 5. Invoking the Data Grid REST API
Data Grid services expose a REST endpoint at port 8443.
By default, Data Grid requires user authentication for data access and encryption for client connections.
- Authentication
-
Data Grid authorizes data access requests with credentials that you specify with the
APPLICATION_USERandAPPLICATION_PASSWORDparameters. - Encryption
-
When Data Grid pods start they generate TLS certificate/key pairs and save them in the
service-certssecret. The TLS certificates are signed by the OpenShift certificate authority (CA).
5.1. Creating External Routes to the REST API Copiar o linkLink copiado para a área de transferência!
REST clients running outside OpenShift access Data Grid pods through routes with reencrypt termination.
Procedure
Create a route with
reencrypttermination.oc create route reencrypt ${ROUTE_NAME} \ --port=https \ --service ${APPLICATION_NAME}$ oc create route reencrypt ${ROUTE_NAME} \ --port=https \ --service ${APPLICATION_NAME}Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc create route reencrypt cache-service-https-route \ --port=https \ --service cache-service
$ oc create route reencrypt cache-service-https-route \ --port=https \ --service cache-serviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run
oc get routesto find the HTTPS route hostname, for example:oc get routes
$ oc get routes NAME HOST/PORT cache-service-https-route cache-service-https-route-rhdg-helloworld.192.0.2.0.nip.ioCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2. Making REST Calls Copiar o linkLink copiado para a área de transferência!
Prerequisite
Configure REST clients for authentication and encryption.
- On OpenShift
-
Create truststores with the CA bundle mounted in the pod at:
/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt - Outside OpenShift
- Create truststores with the CA for your OpenShift environment.
Procedure
Invoke the Data Grid REST API as appropriate.
For example, invoke a
PUTcall to add a key:value pair:curl -X PUT \ -u ${USERNAME}:${PASSWORD} \ -H 'Content-type: text/plain' \ -d 'world' \ https://${HOSTNAME_FOR_HTTPS_ROUTE}/rest/default/hellocurl -X PUT \ -u ${USERNAME}:${PASSWORD} \ -H 'Content-type: text/plain' \ -d 'world' \ https://${HOSTNAME_FOR_HTTPS_ROUTE}/rest/default/helloCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2.1. Using the OpenShift CA to Make REST Calls Copiar o linkLink copiado para a área de transferência!
In cases where the CA certificate is not valid, such as local OpenShift clusters or Red Hat OpenShift Container Platform development installations, you can use service-ca.crt to make REST calls.
Procedure
Get
service-ca.crtfrom Data Grid pods.oc rsync ${pod_name}:/var/run/secrets/kubernetes.io/serviceaccount/..data/service-ca.crt .$ oc rsync ${pod_name}:/var/run/secrets/kubernetes.io/serviceaccount/..data/service-ca.crt .Copy to Clipboard Copied! Toggle word wrap Toggle overflow Pass
service-ca.crtwhen you invoke REST calls.Copy to Clipboard Copied! Toggle word wrap Toggle overflow