Enabling external connections from applications using a load balancer

You can enable external connections from remote applications to your Db2® Event Store database service by creating a new load balancer service.

Procedure

  1. Paste the following configuration into a new file named external-conn.yaml.
    apiVersion: v1
    kind: Service
    metadata:
      name: load-balancer-service-name
    spec:
      loadBalancerIP:
      ports:
      - name: ingest-connection
        port: ingest-port
        protocol: TCP
        targetPort: 9204
      - name: db2-connection
        port: db2-port
        protocol: TCP
        targetPort: 9201
      selector:
        app.kubernetes.io/name: deployment-id-tenant-engine
        component: eventstore
        enabled: "true"
      sessionAffinity: None
      type: LoadBalancer
  2. Replace the following values in the yaml file:
    • load-balancer-service-name: A descriptive name for the load balancer service, for example db2eventstore-1591381507640-tenant-engine-external-svc.
    • ingest-port: A valid port number of your choice. This is the port that the exposed ingest service will be listening on.
    • db2-port: A valid port number of your choice. This is the port that the Db2 client service will be listening on.
    • deployment-id: The deployment ID of your Db2 Event Store deployment, which can be found in the database details page on the Cloud Pak for Data console. (for example, db2eventstore-1578174815082.

    The targetPort values (9204 and 9201) are Db2 Event Store internal ports that the load balancer will connect with.

  3. Create the service by running the following command:
    oc create -f external-conn.yaml
  4. Run the following command to view the new service:
    oc get svc | grep db2eventstore-tenant-engine-external-svc
    The command returns something similar to the following example:
    db2eventstore-tenant-engine-external-svc LoadBalancer 172.30.228.156 example.lb.com <ingest-port>:31040/TCP,<db2-port>:30678/TCP 99s

    In this case, the two services that form the connection endpoint URL are as follows:

    • example.lb.com:<ingest-port>: The connection string for Db2 client connections.
    • example.lb.com:<db2-port>: The connection string for the high-performance ingest port connection.

    If you combine the two connection strings as example.lb.com:<db2-port>;example.lb.com:<ingest-port>, you have the valid connection string that you can use in your applications. This string serves as the substitute for the connection string that is available in the Cloud Pak for Data console.

    For more information, see Creating a load balancer service in the Red Hat® OpenShift® documentation.