-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using extraPortMappings in Windows #1523
Comments
kubernetes nodeports are in the range https://kubernetes.io/docs/concepts/services-networking/service/#nodeport if you forward one of those ports it should work, otherwise you'll want to consider e.g. an ingress, or using a hostport https://kind.sigs.k8s.io/docs/user/ingress/ on linux you can use type=loadblancer using metallb, but not on windows currently due to docker's networking model |
Thank you @BenTheElder for your answer, a few questions:
Thank you for the tip regarding |
Quick example (not tested on windows). I tend to use yaml and kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- hostPort: 31111
containerPort: 31111 kubectl create deploy mynginx --image=nginx
kubectl create service nodeport --node-port=31111 mynginx --tcp=80:80 |
Er sorry, I mean in the kubernetes objects (your pods) rather than in kind.
Before your comment showed up I wrote #1523 (comment), you can see how to do it here without yaml (use
It's not possible natively in kind (or docker), but you can run a "sidecar" container next to the node that just proxies traffic (something like socat) from some port mapped to the host to some port in the node.
Yeah, I would really like this to work, but docker containers are not reachable by IP from the host on windows / mac which is pretty limiting, we have to use these magicalish port forwards to be portable. We have some thoughts about workarounds but ... they're very involved and unlikely to be ready anytime soon, if ever. |
To elaborate a bit...
|
Thank you @BenTheElder for your SUPER fast replies 🙂, I appreciate it I will try things on my Windows machine tomorrow and get back to this issue. Also, sorry if I'm asking a stupid question, but would you by any chance be able to give some pointers about And, I'm OK with trying things to hopefully make PS: I know Windows makes things much harder, but unfortunately I don't have a choice regarding my work machine. Also, since Docker Desktop on Windows requires Hyper-V, I'm having all sorts of problems with VirtualBox, and I can't test things there. All this to say that I regard |
I appreciate the appreciation :-)
Sure, there's a pretty good example here under "Use Case: Publish a port on an existing container": Please do not use For the currently released version of kind you can do: 1) get the node IP:
or
For my cluster right now the node IP is $ kubectl get no -owide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
kind-control-plane Ready master 46m v1.18.2 172.17.0.3 <none> Ubuntu 19.10 5.4.0-26-generic containerd://1.3.3-14-g449e9269 2) Create a container forwarding a port to another port on this IP
Ccurrently in the kind version under development you will need to pass 1) Create a container forwarding a port to another port on this IP
I totally sympathize, this problem applies to mac as well :-) |
This needs to become a guide in the docs once we're done mucking with the network details, almost there, I hope :-) |
Thank you again @BenTheElder for your detailed instructions. Just to make sure I'm not just confusing you with my machine, it may be worth noting that this is not my personal laptop (and it's running Windows), so is it possible that something is messing things up in the network causing the behavior I see below? For example, initially, I had a HUGE delay when I was running Docker commands, and for some reason, adding the following line in my
so, I was wondering if it would be possible for this line to mess things up! I'm not sure if I'm missing something, but
My service:
The output of
I think here, you forgot the
However, this is what I get:
And, in my terminal running
I also tried forwarding to Sorry if this got too long 😛 |
not sure about that
yes, though I recommend you only use one node unless you have a good reason for more.
er right, --net=kind only applies to kind installed from HEAD / the latest code. v0.7.0 does not have this. only this version can use the hostname as well. if you're using kind v0.7.0 or any build not extremely recent you need to use the instructions involving getting the IP. |
The version I have is this: |
Hey @BenTheElder , so I think I've made some progress; the
One thing that was super exciting for me was the fact that I can have multi-node clusters with |
sorry got a bit swamped ...
Yeah... Multi-Node clusters should work everywhere, but do add some more confusion to things like network mapping :-) The most noticeable difference on Linux vs Not-Linux wrt Docker is the network connectivity between the host and the containers, on linux you can poke each container by IP and do all kinds of fun stuff. On mac / windows you'll have to use port forwards where you might not have needed them and generally work around the minimal connectivity :( We strive to make everything we officially ship work the same everywhere as much as possible, and it pretty much does. It does restrict us from e.g. shipping a kubernetes LoadBalancer implementation currently though. |
it probably does, that build unfortunately doesn't have the commit (make does, but not plain go build ...) v0.8.0 actual is out now 😅 |
One thing confusing for me is why it works with a single node and not multi-node (in case of |
sorry I lost this message. Your socat thing needs to forward to where the clsuter is listening, in the multi-node case you'll either want to ensure the workload is "pinned" to a node via label + label selector, or use a nodePort (which is on all nodes). |
Thank you @BenTheElder for your answer |
Hi @farzadmf How do you solve the issue about Connection refused on socat terminal ? |
Hey @afreisinger , it's been a while on this issue, 🙂. TBH, I'm not sure if I was even able to solve the issue! I'll try to remember and let you know if something comes to mind. |
I'm using Docker Desktop on Windows and I'm trying to figure out how to use
extraPortMappings
to access my servicesI'm trying with 2 clusters I created using
kind
, the first one:And my config:
And I do these:
Then, when I try to access:
So, I created another cluster to test:
And my config:
And I try to access this one:
I tried to search in the issues, but I couldn't find a similar one, so sorry if this is a duplicate issue
The text was updated successfully, but these errors were encountered: