Connecting to services remotely

If you need to connect remotely to a service from a local machine, follow these steps to connect.

  1. Authenticate in the OpenShift console.

  2. Go to Workloads > Deployments . Select the project from the Project dropdown where the remote connection to the service will be used. Enter the service name in the search bar and choose the necessary one from the filtered results, for example, user-task-management.

    remote connection 1

  3. Go to the YAML tab. In the editor window, add the following value for the JAVA_OPTS property:

    -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005

    remote connection 2

    Restart the pod.

  4. Download the OpenShift command line interface.

    • 4.1. Click the question mark icon in the upper right corner of the page.

    • Select the Command line tools menu.

    • 4.3. Choose the utility to download from the list according to your operating system.

    • 4.4. Open the downloaded file.

    remote connection 3

    +

  5. Launch the command prompt (cmd) from the location where the oc.exe file is located.

    remote connection 4

  6. Obtain the token for authorization in OpenShift.

    • 6.1. Click on your profile name in the upper right corner of the page and select the Copy login command menu item.

      remote connection 5

    • 6.2. Re-authenticate in the system.

    • 6.3. Click Display Token.

    • 6.4. Copy the value from the Log in with this token field.

      remote connection 6

  7. Execute the copied command in the command prompt (cmd), for example:

    oc login --token=sha256~1aWEXnvr4IBVNsrdepqDl5Q10NkhokW7nt-s_-trO8k --server=https://api.cicd2.mdtu-ddm.projects.epam.com:6443
    • 7.1. Next, select the appropriate project by executing the command:

      oc project some_name

      where some_name is the name of your project.

    • 7.2. Obtain the pod identifier of the service by executing the command:

      oc get pods
    • 7.3. Execute the port forwarding command:

      oc port-forward user-task-management-c8b9695d6-rg92b 5005:5005
  8. Add a new configuration in IntelliJ IDEA.

    • 8.1. Go to the Run  Edit Configuration…​.

      remote connection 7

    • 8.2. Click Add New Configuration and select the Remote JVM Debug configuration type.

      remote connection 8

    • 8.3. Specify the name and verify the settings, then click OK.

      remote connection 9

  9. Start the service.

    remote connection 10

  10. Upon the next request, the service can now be intercepted on the local machine.

    remote connection 11