Enabling the Db2 REST interface

You can enable the Db2 REST interface for an existing Db2 deployment on IBM® Software Hub.

Procedure

  1. During or after your provisioning of the Db2 service instance, you can edit the Db2uCluster or Db2uInstance custom resource. Find your respective resource name by running the following command for Db2uCluster or Db2uInstance:
    oc get db2ucluster,db2uinstance
  2. Set the environment variable DB2_CR_ID with your Db2uCluster or Db2uInstance custom resource name.
    DB2_CR_ID=<db2ucluster_name/db2uinstance_name>
  3. Run the following command for Db2uCluster or Db2uInstance to edit the add-ons file:
    oc edit db2ucluster ${DB2_CR_ID}
    oc edit db2uinstance ${DB2_CR_ID}
    Set the rest value to enabled: true. The edited file should look like the following example:
    addOns:
      rest:
        enabled: true
  4. Run the following command to view the REST service and deployment information:
    oc get formations.db2u.databases.ibm.com db2oltp-1603819662989 -o go-template='{{range .status.components}}{{printf "%s,%s,%s\n" .kind .name .status.state}}{{end}}' | column -s, -t 
    The results should look similar to the following example:
    service                c-db2oltp-1603819662989-db2u-rest-svc          Creating
    Deployment             c-db2oltp-1603819662989-rest                   Creating
  5. Run the following command to view the REST pod as part of your deployment:
    oc get pods |grep db2
    Here is an example with the REST pod highlighted:
    c-db2oltp-1603819662989-db2u-0                               1/1     Running     0          39m
    c-db2oltp-1603819662989-etcd-0                               1/1     Running     0          39m
    c-db2oltp-1603819662989-instdb-df7hh                         0/1     Completed   0          40m
    c-db2oltp-1603819662989-ldap-64bc6d58dc-ms29x                1/1     Running     0          40m
    c-db2oltp-1603819662989-rest-66f7fcb7d4-98fbh                1/1     Running     0          86s
    c-db2oltp-1603819662989-restore-morph-bkfpr                  0/1     Completed   0          39m
    c-db2oltp-1603819662989-tools-57bc7d4ddf-wz8fr               1/1     Running     0          40m
    db2u-operator-5999cd944b-dwgrr                             1/1     Running     0          17m
    Note the REST pod name, which is used to run documented REST commands.

What to do next

After you enable the Db2 REST service, you can create the route for the service.