Following steps can be used to debug java application running on Remote Cluster, for sake of similicity I am using bare minimum pod config to spin the HS2 pod on the cluster.
-
Build a docker image as per https://gist.github.com/rajkrrsingh/e2a5d02a3a895c7f7e8f1d6d0e71e0e9, The image push the debug config -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n to the JVM opts, the same can be achieved through the ConfigMap descriptor.
-
Create HS2 Deployments
apiVersion: apps/v1
kind: Deployment
metadata:
name: hs2
namespace: default
labels:
app: hs2
spec:
replicas: 1
selector:
matchLabels:
app: hs2
template:
metadata:
labels:
app: hs2
spec:
containers:
- name: hs2
image: rajkrrsingh/hive3-image-debug:latest
imagePullPolicy: Always
ports:
- containerPort: 10000
name: binary
- port forwards
// JDBC endpoint
kubectl port-forward --address 0.0.0.0 hs2-5d6d47b5bd-d86tm 10000:10000
// Debugger endpoint
kubectl port-forward --address 0.0.0.0 hs2-5d6d47b5bd-d86tm 8000:8000
- Now though IDE you can connect the debugger to Kubernetes node on port 8000 and start debugging.