<p>I need to debug (with chrome://inspect/ debugger) my nodejs app while it is deployed in a kubernetes pod.  I tried adding a port to the service in front of the deployment but this is not working.</p>

<p>I added the port 42126</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: account-service # matches name in nginx.conf 
spec:
  ports:
  - name: traffic
    port: 80
    targetPort: 80
  - name: debug
    port: 42126
    targetPort: 42126
  type: NodePort # speculating need this so nginx can route to this ???????
  selector:
    app: account-pod # matches name of pod created by deployment account-deployment
</code></pre>

<p>The deployment is not modified</p>

<pre><code>apiVersion: apps/v1beta2 # for version 1.8, once 1.9 switch to apps/v1
kind: Deployment
metadata:
  name: account-deployment # name of the deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: account-pod # matches name of pod to create
  template:
    metadata:
      labels:
        app: account-pod # name of pod, matches deployment and service definition
    spec:
      containers:
      - name: account-container # name of docker container
        image: us.gcr.io/purple01-0000000/purple_account:2018_04_25_18_08
</code></pre>

<p>The docker image is created with the following.  I know this works since I use it for debugging locally when running docker compose with all my modules.</p>

<pre><code>FROM node:9.4
WORKDIR /app

COPY . /app/
RUN npm install

# comment out normal mode and created one for the debug
#CMD node ./bin/www  
CMD node --inspect-brk=0.0.0.0:42126 ./bin/www

EXPOSE 80 42126
</code></pre>

<p>The configured ingress send the http traffic to an nginx service that 
serves static files and routes to various micro services.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: basic-ingress
  annotations: 
    kubernetes.io/ingress.global-static-ip-name: ingress-ip 
spec:
  tls:
  - secretName: tls-secret
  backend:
    serviceName: purple-front-end-service 
    servicePort: 80
</code></pre>

<p>I am new to kubernetes, so any advice is appreciated.</p>

<p>One of the many things I don't get: ingress terminates https and sends the http to my purple-front-end-service (a nginx service).  How is port 42126 on the account-service made available to the outside so I can connect to it via chrome?</p>

<p>What do I configure in the "Target discovery settings" for "chrome://inspect/#devices".</p>

<p>in the Dockerfile that creates your application, enable debugging (see line CMD)</p>

<pre><code>FROM node:9.4
WORKDIR /app
COPY ./app.js /app/app.js
COPY ./package.json /app/package.json
RUN npm install
CMD node --inspect-brk=0.0.0.0:42132 ./bin/www
</code></pre>

<p>Using the "Google Cloud Platform" website
Kubernetes Engine / Workloads / 
Select the deployment from the displayed list to show details.
Scroll down to "Managed pods" and note the name.</p>

<p>In the detail section of the service there is a "port forwarding" button that reveals the command.
<a href="https://i.stack.imgur.com/53sZu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/53sZu.png" alt="enter image description here"></a></p>

<p>On your desktop, run the command using the pods name and port # you want to use.
    kubectl port-forward account-deployment-85f7dcf65b-v27zx 8080:42126</p>
