Maximo

Maximo

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

 View Only
Expand all | Collapse all

Accessing Db2 database inside OpenShift cluster

  • 1.  Accessing Db2 database inside OpenShift cluster

    Posted Fri July 07, 2023 12:52 PM

    I've finally managed to finish my MAS Manage installation on a Single-Node OpenShift cluster. Done so using the ansible masdevops collection and once you know what you are doing (and the settings that need tweaking) it works like a charm.

    Now that I've done so, I still have many interrogations.

    One of them is : how can I query the database? It being inside the OpenShift cluster

    I see there are many "Services" for the DB instance in OpenShift, and one actual "Route"

    https://db2w-shared-db2u.apps.cluster.domain.com

    I tried using that URL and port 50001 with proper username and password from SQL Developer but without much luck

    Am I on the right track or there is something I don't understand?



    ------------------------------
    Francois Beliveau
    ------------------------------


  • 2.  RE: Accessing Db2 database inside OpenShift cluster

    Posted Sat July 08, 2023 05:21 PM

    I've managed to do it. Not sure it's the easiest way but it involves using oc command line port forwarding to make it that, for example, localhost:12345 points to the db2 pod, port 50001

    You also need to get the certificate, add it to your SQL Developer truststore, and set up your connection profile to use localhost, whatever port you used for the port forwarding, and you are ready to go

    Downside is you need to start port forwarding each and every time but that's not so bad



    ------------------------------
    Francois Beliveau
    ------------------------------



  • 3.  RE: Accessing Db2 database inside OpenShift cluster

    Posted Mon July 10, 2023 02:34 AM

    Actually, You do not have to do anything like You've mentioned.

    If You've deployed DB2 using MAS devops scripts, You will find that there is one Route in the db2u namespace and if You go to the Service on which this Route is based on, You will find that is had NodePort access enabled. This means that You can access DB2 instance using IP address of any of the OCP nodes (in case of SNO that is just one IP address) and the port listed under 'Service Port mapping'. Default MAS devops deployment will open up two ports: one for SSL enabled communication and second for nonSSL, so You do not need cert also.



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



  • 4.  RE: Accessing Db2 database inside OpenShift cluster

    Posted Mon July 10, 2023 08:22 AM

    Port-forwarding works, but it is just extra steps and not very convenient. There is a Route available in the db2 project. Use that as a host. DB2's port 50000 and 50001 are mapped to randomly generated port numbers of OCP (you'll see those if you trace them in the Service section from the Route). Additionally, you can also use db2 pod's command line via Terminal (su - db2inst1) to query the database from the terminal. Certificate is only needed for SSL connection.



    ------------------------------
    Arif Ali
    ------------------------------



  • 5.  RE: Accessing Db2 database inside OpenShift cluster

    Posted Mon July 10, 2023 08:31 AM

    Thanks that worked like a charm



    ------------------------------
    Francois Beliveau
    ------------------------------



  • 6.  RE: Accessing Db2 database inside OpenShift cluster

    Posted Sun November 19, 2023 11:31 PM
    Edited by Muhammad haris bin javaid Sun November 19, 2023 11:31 PM

    Hi, 

    I am trying to access it using route host name and port 50000, 50001 but its giving me connection timeout error only port that works is 443 but it needs certificate.

    I want to access it without using certificate outside openshift

    Reagrds

    Muhammad haris bin javaid



    ------------------------------
    Muhammad haris bin javaid
    ------------------------------



  • 7.  RE: Accessing Db2 database inside OpenShift cluster

    Posted Mon November 20, 2023 08:54 AM

    When externally connecting to a database running in OCP, you must use NodePort (which are randomly assigned port numbers mapped to the database port numbers). As mentioned above, if you have used MAS devops scripts to deploy Manage, you will see a Route in db2 project. Use that route URL (without https) as a host. Use the randomly assigned NodePort number to port 50000 (locate that number, starts with 32, in the Services section under Networking). It will connect successfully.



    ------------------------------
    Arif Ali
    ------------------------------



  • 8.  RE: Accessing Db2 database inside OpenShift cluster

    Posted Mon November 20, 2023 09:31 AM
    Edited by Muhammad haris bin javaid Mon November 20, 2023 09:34 AM

    Hi, 

    I used the hostname in the route and nodeport assigned to 5000 but it still giving connection timeout error when i am doing telnet 



    ------------------------------
    Muhammad haris bin javaid
    ------------------------------



  • 9.  RE: Accessing Db2 database inside OpenShift cluster

    Posted Mon July 08, 2024 06:54 PM

    @Francois Beliveau when you say tweaking settings, what do you mean? I'm standing up single node as we speak for my organization's POC and can get core up just fine. My problem is that I run out of compute resources when trying to deploy manage on top of it. I've tried limiting the compute consumption using resource quotas but didn't have any luck. I also threw more cores and memory at the situation too, and still no luck. Any help you could suggest would be amazing. Thanks!



    ------------------------------
    Brett Coleman
    ------------------------------



  • 10.  RE: Accessing Db2 database inside OpenShift cluster

    Posted Thu January 16, 2025 06:06 AM

    If it helps, I have written a short article describing one possible approach to this topic:

    https://www.linkedin.com/pulse/recipe-accessing-db2-database-openshift-cluster-from-outside-diego-hesnf 



    ------------------------------
    Diego Visentin
    EAM BU Director
    Tempestive S.p.A.
    ------------------------------