<p>Now I am remote debugging my java program in kubernetes(v1.15.2) using kubectl proxy forward like this:</p>

<pre><code>kubectl port-forward soa-report-analysis 5018:5018 -n dabai-fat
</code></pre>

<p>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? </p>

<p>I use this script to improve my workflow:</p>

<pre><code>#!/usr/bin/env bash


set -u

set -e

set -x

kubectl get pods -n dabai-fat | grep "soa-illidan-service"

POD=$(kubectl get pod -l k8s-app=soa-illidan-service -o jsonpath="{.items[0].metadata.name}")

kubectl port-forward ${POD} 11014:11014
</code></pre>

<p>This script automatic get the pod name and open remote debugging.</p>
