title: Remote debug container in kubernetes using intellij
body: <p>I try to remote debug the application in attached mode with host: <code>192.168.99.100</code> and port <code>5005</code>, but it tells me that it is <code>unable to open the debugger port</code>. The IP is <code>192.268.99.100</code> (the cluster is hosted locally via minikube).</p>
  
  <p>Output of <code>kubectl describe service catalogservice</code></p>
  
  <pre><code>Name:                     catalogservice
  Namespace:                default
  Labels:                   &lt;none&gt;
  Annotations:              &lt;none&gt;
  Selector:                 app=catalogservice
  Type:                     NodePort
  IP:                       10.98.238.198
  Port:                     web  31003/TCP
  TargetPort:               8080/TCP
  NodePort:                 web  31003/TCP
  Endpoints:                172.17.0.6:8080
  Port:                     debug  5005/TCP
  TargetPort:               5005/TCP
  NodePort:                 debug  32003/TCP
  Endpoints:                172.17.0.6:5005
  Session Affinity:         None
  External Traffic Policy:  Cluster
  Events:                   &lt;none&gt;
  </code></pre>
  
  <p>This is the pods service.yml:</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: catalogservice
  spec:
    type: NodePort
    selector:
      app: catalogservice
    ports:
    - name: web
      protocol: TCP
      port: 31003
      nodePort: 31003
      targetPort: 8080
    - name: debug
      protocol: TCP 
      port: 5005
      nodePort: 32003
      targetPort: 5005
  </code></pre>
  
  <p>And in here I expose the containers port</p>
  
  <pre><code>spec:
    containers:
    - name: catalogservice
      image: elps/myimage
      ports:
      - containerPort: 8080
        name: app
      - containerPort: 5005
        name: debug
  </code></pre>
  
  <p>The way I build the image:</p>
  
  <pre><code>FROM openjdk:11
  VOLUME /tmp
  EXPOSE 8082
  ADD /target/catalogservice-0.0.1-SNAPSHOT.jar catalogservice-0.0.1-SNAPSHOT.jar
  ENTRYPOINT ["java", "-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n", "-jar", "catalogservice-0.0.1-SNAPSHOT.jar"]
  </code></pre>
  
  <p>When I execute <code>nmap -p 5005 192.168.99.100</code> I receive</p>
  
  <pre><code>PORT     STATE  SERVICE
  5005/tcp closed avt-profile-2
  </code></pre>
  
  <p>When I execute <code>nmap -p 32003 192.168.99.100</code> I receive</p>
  
  <pre><code>PORT     STATE  SERVICE
  32003/tcp closed unknown
  </code></pre>
  
  <p>When I execute <code>nmap -p 31003 192.168.99.100</code> I receive</p>
  
  <pre><code>PORT     STATE  SERVICE
  31003/tcp open unknown
  </code></pre>
  
  <p>When I execute <code>kubectl get services</code> I receive</p>
  
  <pre><code>NAME              TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                          AGE
  catalogservice    NodePort    10.108.195.102   &lt;none&gt;        31003:31003/TCP,5005:32003/TCP   14m
  </code></pre>
  
  <p><code>minikube service customerservice --url</code> returns </p>
  
  <pre><code>http://192.168.99.100:32004
  </code></pre>