Creating the route for the Db2 REST service

After you enable the Db2 REST service, you need to create a route to expose the REST server to clients that reside outside of the cluster.

Before you begin

Before you create the route, you need the name of the Db2 REST service. Run the following command to find the service name:

oc get svc |grep db2u-rest-svc

The result looks similar to the following example:

c-db2oltp-1621977491245678-db2u-rest-svc   NodePort    172.30.84.121   <none>    50050:31812/TCP   27m

In the preceding example, the Db2 REST service name is c-db2oltp-1621977491245678-db2u-rest-svc.

Procedure

  1. To create a route, run the following command:
    oc create route passthrough rest --service rest_service_name

    Using the preceding example, rest_service_name would be c-db2oltp-1621977491245678-db2u-rest-svc.

  2. To view the route that you created, run the following command:
    oc get routes

    The result looks similar to the following example:

    
    NAME        HOST/PORT                                         PATH   SERVICES                                    PORT                   TERMINATION            WILDCARD
    cpd         cpd-zen.apps.db2restgraph.cp.fyre.ibm.com                ibm-nginx-svc                               ibm-nginx-https-port   passthrough/Redirect   None
    rest        rest-zen.apps.db2restgraph.cp.fyre.ibm.com               c-db2oltp-1621977491245678-db2u-rest-svc    rest-server            passthrough            None
    

Example

The following example shows the URL for a Db2 REST server: https://rest-zen.apps.db2restgraph.cp.fyre.ibm.com/docs.

What to do next

After you create a route, see Using the REST interface with Db2.

Tip:
After creating a route, consider updating the default values for the following parameters in your /etc/haproxy/haproxy.cfg file:
  • timeout client
  • timeout server

The default values are each set at 1 minute. With these settings, the Db2 REST service that takes longer than 1 minute will encounter timeout errors. If long running services are necessary for your usage, consider updating the default values to be greater than the default HTTP timeout value of two minutes.

To apply your changes to the /etc/haproxy/haproxy.cfg file, run the following command:
systemctl reload haproxy