<p>I currently have a go app that uses a lot <code>fmt.printf</code>. Whenever that app would run in a pod I was able to get the logs back by doing</p>
<p><code>kubectl logs podname</code></p>
<p>However I also needed to integrate remote debugging. I need to use <code>dlv</code> to allow my ide(GoLand) to remotely connect to the pod. It connects to the Pod at port 40000.
Also when the Pods image runs it exposes port 40000 i.e the docker file has this in it 40000</p>
<p>I also have a service that looks like this in my minikube</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: mydebug
spec:
  type: ClusterIP
  selector:
    app: fooapp
  ports:
  - protocol: TCP
    port: 40000
    targetPort: 40000
    name: delve
</code></pre>
<p>Now when I do <code>kubectl logs podname</code> I only get this back</p>
<pre><code>API server listening at: [::]:40000
2022-10-30T21:18:57Z warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted)
</code></pre>
<p>Is there anyway to get my logs back ? Ho</p>

<p>You can use the <code>--continue</code> exec flag, to continue the debugged process on the start, which then will lead to continued logs.</p>
<p>So start delve e.g. with:</p>
<pre><code>dlv --listen=:2345 --headless exec your/app --continue
</code></pre>
<p>Without the <code>--continue</code> flag, delve will wait for remote connections and halt your application. With the <code>--continue</code> flag, the application instead will start already.</p>
<p>From <code>dlv help exec</code>:</p>
<pre><code>...
Usage:
  dlv exec &lt;path/to/binary&gt; [flags]

Flags:
      --continue     Continue the debugged process on start.
...
</code></pre>
