Now I am remote debugging my java program in kubernetes(v1.15.2) using kubectl proxy forward like this:
kubectl port-forward soa-report-analysis 5018:5018 -n dabai-fat
I could using intellij idea to remote connect my localhost port 5018 to remote debugging my pod in kubernetes cluster in remote datacenter,but now I am facing a problem is every time I must change the pod name to redebug after pod upgrade,any way to keep a stable channel for debugging?
We can use a service of type nodeport to resolve your issue.Here is a sample yaml file:-
apiVersion: v1
kind: Service
metadata:
name: debug-service
spec:
type: NodePort
selector:
app: demoapp
ports:
# By default and for convenience, the `targetPort` is set to the same value as the `port` field.
- port: 8001 // port which exposed in DockerFile for debugging purpose
targetPort: 8001
# Optional field
# By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767)
nodePort: 30019
In IntelliJ, you will be able to connect to
Host: localhost
Port: 30019