Open AlexFsmn opened 3 years ago
@AlexFsmn This is expected as Bridge To Kubernetes would be setting up network traffic such that, if required, the communication from the local dev machine to the service using port 99 on the cluster can be achieved. So any process on the dev machine that is using the port which is also being used by a service on the cluster, would be killed to allow inter service communication.
In your current setup with docker-desktop, it is not possible to kill the process com.docker.backend.exe
, and hence the failure with debugging.
For these scenarios, Bridge To Kubernetes supports using Kubernetes Service Environment variables where killing process, providing admin credentials are not required.
The documentation goes over the feature in detail and how to set it up. Please feel free to ask any questions you have in using the Kubernetes Service Environment variables
feature.
Correct me if I'm wrong but the documentation you linked doesn't say anything about limitations for local Kubernetes clusters. This is from the documentation you linked:
The redirection works in most scenarios, but fails in the case where the Bridge to Kubernetes process has restricted privilege, such as when the request originates from a non-elevated user account or when using VS Code Remote SSH.
If I understand you correctly this should be added to the documentation since this is a limitation for local Kubernetes clusters? And yes, I am running VS Code as admin.
@AlexFsmn Yes, you are right. I'll get the documentation updated to reflect about local Kubernetes clusters.
I am using Visual Studio 2019 extension and seeing this issue.
Can you give an example of which variables to set and where to set them to overcome this issue.
I am using this article and it works perfectly but fails with the same code as above when using the bridge https://faun.pub/how-to-deploy-a-net-5-api-in-a-kubernetes-cluster-53212af6a0e2
When facing this issue in VS Code I was missing this line of code in tasks.json:
"useKubernetesServiceEnvironmentVariables": true,
Not sure if this helps but there should be something similar that you might need to set in Visual Studio 2019.
Also, maybe this could be helpful if you haven't seen this already: https://docs.microsoft.com/en-us/visualstudio/containers/bridge-to-kubernetes?view=vs-2019
@AlexFsmn Thanks for pointing out the doc for VS Code.
@englishguy64 As of now, we have not yet enabled the Kubernetes Service Environment Variables
feature in Visual Studio. This is in progress and would be available soon. If possible can you use VS Code for debugging or use mini-kube with which you wouldn't see this issue?
@AlexFsmn Thanks for pointing out the doc for VS Code. @englishguy64 As of now, we have not yet enabled the
Kubernetes Service Environment Variables
feature in Visual Studio. This is in progress and would be available soon. If possible can you use VS Code for debugging or use mini-kube with which you wouldn't see this issue?
Thanks for the update
When facing this issue in VS Code I was missing this line of code in tasks.json:
"useKubernetesServiceEnvironmentVariables": true,
Not sure if this helps but there should be something similar that you might need to set in Visual Studio 2019.
Also, maybe this could be helpful if you haven't seen this already: https://docs.microsoft.com/en-us/visualstudio/containers/bridge-to-kubernetes?view=vs-2019
Cheers I will try VS Code with your setting. I tried the To Do app and had the same result.
Any news on this? VS2019 16.11.2: Docker desktop with kubes 4.0.1.
@AlexFsmn Yes, you are right. I'll get the documentation updated to reflect about local Kubernetes clusters.
Where is this updated documentation?
Ok, so I completed the setup in VS Code and tried to debug a pod but I got this:
Process 'PID XXXX [com.docker.backend.exe]' binds to port '99' on all addresses. This will prevent 'Bridge To Kubernetes' from forwarding network traffic on this port. Please stop this process or service and try again.
The port in the exception refers to a port used by another pod in the cluster (not the pod I'm activley trying to debug). I should probably mention that this is another image as well. This port isn't the same one that I'm trying to redirect traffic to.
Since I'm really new to this I'm unsure if I did something wrong or if this is a bug. I tried searching for people with similar issues but didn't find any. I also tried to change the port to something else but no luck. Killing the process puts docker in a bad state and needs to be restarted to work properly again. The strange thing is that I tried to input 0 as a port number here which didn't make a difference:
I'm running Linux containers on Windows 10 and I'm using a local Kubernetes cluster through Docker for Windows. I'm using the latest version of Bridge to Kubernetes which is 1.0.120210220 atm. I also tried downgrading to version 1.0.120210126 but didn't make a difference.
Any ideas what could be wrong?