k3d icon indicating copy to clipboard operation
k3d copied to clipboard

[BUG] Port mapping on server with no LB

Open arash-bizcover opened this issue 2 years ago • 2 comments

Scope of your request

Do you need...

  • different functionality for an existing command/flag
    • ports:

Describe the solution you'd like

We should be able to use ports (port mapping) on the server docker as well (without LoadBalancer), currently when putting server:0 as nodeFilter in the ports, I get an error saying FATA[0000] failed to transform ports: port-mapping of type 'proxy' specified, but loadbalancer is disabled

I'm running the whole cluster and a ingress controller all in 1 docker (server:0) and need to be able to port map on server:0

arash-bizcover avatar Jan 23 '23 22:01 arash-bizcover

As a matter of fact there seems to be a bug as well: I set nodeFilter to server:0 and enable the loadbalancer, the nodeFilter is ignored and the mapping still happens on lb docker:

Setting this in k3d.config: image

ports on serverlb: image

ports on server-0: image

arash-bizcover avatar Jan 23 '23 23:01 arash-bizcover

Had the same issue. Turns out, the trick is to add :direct at the end:

k3d cluster create --port "8080:8080@server:0:direct" --no-lb

Only two containers will be created, in particular the server-0 gets the port mapping:

~ ❯ docker ps                                                                                                                                                                                                      9s
CONTAINER ID   IMAGE                            COMMAND                  CREATED          STATUS         PORTS                                             NAMES
af23d04605ef   ghcr.io/k3d-io/k3d-tools:5.4.7   "/app/k3d-tools noop"    9 seconds ago    Up 9 seconds                                                     k3d-k3s-default-tools
298f1b9d5473   rancher/k3s:v1.25.6-k3s1         "/bin/k3d-entrypoint…"   10 seconds ago   Up 8 seconds   0.0.0.0:8080->8080/tcp, 0.0.0.0:62148->6443/tcp   k3d-k3s-default-server-0

MajorBreakfast avatar Feb 16 '23 21:02 MajorBreakfast