Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  How to use DB2 out side of openshift.

    Posted Tue August 08, 2023 02:29 AM

    Hello,

    I have requirement where I have to use the db2 outside on OpenShift on any DB2 software like DBeaver.

    I provide the login details to connect it but still failed.

    Can anyone please guide me for this how I can achieve this.



    ------------------------------
    vaibhav phalle
    ------------------------------


  • 2.  RE: How to use DB2 out side of openshift.

    Posted Tue August 08, 2023 03:20 AM

    Hi Vaibhav,

     

    The easiest way to this is using the oc proxy to the pod.  Using the Openshift oc application connect to your Openshift cluster. Something like this:

     

    login --token=sha256~zvhWDRZItvq0Qnx60epoDnU4L0hfZa5ORjzBM --server=https://api.sharptree.app:6443

     

    Then using the oc port-forward command to expose database port on your local machine.  Assuming your DB2 port is 50005 it would look something like this:

     

    oc port-forward <db2_pod_name> 50005:50005 -n <namespace/project_name>

     

    Then you would set up your connect string on your desktop to point to localhost at port 50005.

     

    Full documentation is here:

    https://docs.openshift.com/container-platform/4.10/nodes/containers/nodes-containers-port-forwarding.html

     

    You can also set up a TCP route, but that is more complicated and has security implications you probably don't want to address unless you are granting wider access to the database than your personal use.

     

    Regards,

    Jason

     

     






  • 3.  RE: How to use DB2 out side of openshift.

    Posted Tue August 08, 2023 02:32 PM

    Thank You So Much Sir For This Help!



    ------------------------------
    vaibhav phalle
    ------------------------------



  • 4.  RE: How to use DB2 out side of openshift.

    Posted Wed August 09, 2023 01:52 AM

    If You have deployed DB2 using the MAS DevOps Ansible scripts it is by default already exposed to the outside via NodePort. To find the address and port go to Network > Services, change the project to db2u and look for a service called something like this 'c-db2w-shared-db2u-engn-svc'. Click on that and in the new view there is a section called Service Port mapping for both SSL and non-SSL ports. In DBeaver You need to use the Node Ports (violet ones). The address in just any node address.



    ------------------------------
    Witold Wierzchowski
    ------------------------------



  • 5.  RE: How to use DB2 out side of openshift.

    Posted Wed August 09, 2023 09:32 AM

    Hi Vaibhav,

    this is how I did it for our DEV instance.

    oc get svc -n db2u | grep engn-svc
    ## c-db2u-manage-db2u-engn-svc   NodePort    172.30.9.255    <none>        50000:30168/TCP,50001:31520/TCP

    oc create route passthrough db2-manage-route -n db2u --port ssl-server --service c-db2u-manage-db2u-engn-svc --insecure-policy=None

    oc get route db2-manage-route -n db2u -o jsonpath="{.spec.host}{'\n'}"
    ## db2-manage-route-db2u.apps.[openshift_domain]

    oc get secret -n db2u c-db2u-manage-instancepassword -o jsonpath="{.data.password}" | base64 -d ; echo
    ## XXXXXXX

    oc get secret -n db2u db2u-ca -o jsonpath="{.data.ca\.crt}" | base64 -d > /tmp/db2-ca.pem

    cd /tmp

    keytool -importcert -keystore certdb2.jks -storepass password123 -file db2-ca.pem -alias cert

    Dbeaver setup - DB2 LUW

    ## Main tab
    Host: db2-manage-route-db2u.apps.[openshift_domain]
    Port: 443
    Database: BLUDB
    Username: db2inst1
    Password: XXXXXXX

    ## Driver Properties tab
    sslConnection=True
    TrustServerCertificate=True
    sslTrustStoreType=jks
    sslTrustStoreLocation=C:\certdb2.jks
    sslTrustStorePassword=password123



    ------------------------------
    Jan Ondrusek
    ITspec
    IBM
    n/a
    ------------------------------