<p>I am trying to follow the instructions on this webpage to debug an app deployed to Kubernetes in Visual Studio 2019: <a href="https://github.com/VladimirAkopyan/DockerDotnetDebug" rel="nofollow noreferrer">https://github.com/VladimirAkopyan/DockerDotnetDebug</a>.  The instructions (in case the webpage is every brought down are as follows):</p>

<pre><code>1) docker run -d -p 2222:2222 -p 5000:5000 clumsypilot/dotnetdebug:asp-debug-sample
2) Open Localhost:5000 and verify thee website is running.
3) Clone the Repo and open project DotnetDebug in VS2017
4) Setup a remote connection over SSH
5) Set a breakpoint in DebugSample/Pages/Index.cshtml.cs
6) Start debugger and reload page!
7) Alternatively, debug this container while it's running on a kubernetes cluster using
kubectl port-forward &lt;POD-NAME&gt; 2222
</code></pre>

<p>The instructions are described in more detail here: <a href="https://blog.quickbird.uk/debug-netcore-containers-remotely-9a103060b2ff" rel="nofollow noreferrer">https://blog.quickbird.uk/debug-netcore-containers-remotely-9a103060b2ff</a></p>

<p>Steps 1-6 are clear and work very well.  However, I am stuck on step 7.  How do I deploy the container to Kubernetes and then port-forward the pod? I have tried this:</p>

<pre><code>kubectl run my-app --image=clumsypilot/dotnetdebug:asp-debug-sample --port=5000
kubectl port-forward my-app-d664fc4c9-hw66j 2222
</code></pre>

<p>I then try to browse to: <a href="http://localhost:5000" rel="nofollow noreferrer">http://localhost:5000</a> and see this error:</p>

<pre><code>SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u3 Protocol mismatch. 
</code></pre>

<p>What am I doing wrong?</p>

w0051977
<p>I cannot find any documentation that explains how to do this online so I am going to post an answer:</p>

<pre><code>1) kubectl run my-app --image=clumsypilot/dotnetdebug:asp-debug-sample --port=5000
2) kubectl expose deployment my-app --type=LoadBalancer --port=8080 --target-port=5000 //not sure why you put my-app here and not the full app name i.e. my-app-d664fc4c9-k8s26 2222 in this case.
3) kubectl get pods //to get the pod name
</code></pre>

<p><a href="https://i.stack.imgur.com/tNfIq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tNfIq.png" alt="enter image description here"></a></p>

<pre><code>4) kubectl port-forward my-app-d664fc4c9-k8s26 2222
</code></pre>

<p>Then I can browse to <a href="http://localhost:8080" rel="nofollow noreferrer">http://localhost:8080</a> in a web browser:</p>

<p><a href="https://i.stack.imgur.com/IauCo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IauCo.png" alt="enter image description here"></a></p>

<p>and the debugger stops when I load the homepage:</p>

<p><a href="https://i.stack.imgur.com/NKOIy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NKOIy.png" alt="enter image description here"></a></p>

<p>Attatch to process looks like this in Visual Studio:</p>

<p><a href="https://i.stack.imgur.com/3F3ET.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3F3ET.png" alt="enter image description here"></a></p>

<p>Connect to Linux container like this:</p>

<p><a href="https://i.stack.imgur.com/f3ktF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f3ktF.png" alt="enter image description here"></a></p>

<p>The root password is in the dockerfile.</p>

<p>To start te instructions again:</p>

<p>1) Delete deployment: <code>kubectl delete deployment my-app</code>
2) Delete pod: <code>kubectl delete pod my-app-d664fc4c9-t7ft9</code>
3) Delete service: <code>kubectl delete service my-app</code></p>

<p>To get the names use:</p>

<p>1) kubectl get deployment
2) kubectl get pod
3) kubectl get service</p>
