Connecting to services remotely
If you need to connect remotely to a service from a local machine, follow these steps to connect.
-
Authenticate in the OpenShift console.
-
Go to
Workloads
>Deployments
. Select the project from theProject
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
. -
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
Restart the pod.
-
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.
+
-
-
Launch the command prompt (cmd) from the location where the oc.exe file is located.
-
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. -
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.
-
-
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
-
-
Add a new configuration in IntelliJ IDEA.
-
8.1. Go to the
. -
8.2. Click
Add New Configuration
and select theRemote JVM Debug
configuration type. -
8.3. Specify the name and verify the settings, then click
OK
.
-
-
Start the service.
-
Upon the next request, the service can now be intercepted on the local machine.