Skip to content
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

kubectl port-forwarding fails during use with moby: socat missing on VM #1250

Closed
ericpromislow opened this issue Jan 14, 2022 · 3 comments · Fixed by #1280
Closed

kubectl port-forwarding fails during use with moby: socat missing on VM #1250

ericpromislow opened this issue Jan 14, 2022 · 3 comments · Fixed by #1280
Labels
kind/bug Something isn't working
Milestone

Comments

@ericpromislow
Copy link
Contributor

ericpromislow commented Jan 14, 2022

Rancher Desktop Version

dev->1.0.0-beta1

Rancher Desktop K8s Version

1.21.6

What operating system are you using?

macOS

Operating System / Build Version

macOS Monterey 12.0.1

What CPU architecture are you using?

x64

Windows User Only

No response

Actual Behavior

Terminal 1:

$ kubectl port-forward $ALPACA_POD 48858:8080
Forwarding from 127.0.0.1:48858 -> 8080
Forwarding from [::1]:48858 -> 8080

Terminal 2:

curl http://localhost:48858/

Back to Terminal 1:

Handling connection for 48858
E0114 14:08:58.698803   17224 portforward.go:406] an error occurred forwarding 48858 -> 8080: error forwarding port 8080 to pod c5993e2de9902e4bb3fe8c579d8c41613fa34af5b67b6ecdbeaab5f4521c8574, uid : unable to do port forwarding: socat not found
E0114 14:08:58.699114   17224 portforward.go:234] lost connection to pod

Fix is to run sudo apk add socat on the VM

Steps to Reproduce

Ensure you're using the moby container engine. No problem with containerd

Do the following in terminal 1:

Install the sample app:

kubectl run alpaca-prod   --image=gcr.io/kuar-demo/kuard-amd64:blue --port=8080 --labels="ver=1,app=alpaca,env=prod"

Background on kubectl:

$ which kubectl
/usr/local/bin/kubectl

$ ls -l /usr/local/bin/kubectl
lrwxr-xr-x  1 OWNER GROUP 67 12 Jan 15:09 /usr/local/bin/kubectl -> .../workspace/rancher/desktop/resources/darwin/bin/kubectl

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.1", GitCommit:"86ec240af8cbd1b60bcc4c03c20da9b98005b92e", GitTreeState:"clean", BuildDate:"2021-12-16T11:41:01Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.1+k3s2", GitCommit:"a0cadcd3436745396c82821b4a0803ee460401e1", GitTreeState:"clean", BuildDate:"2022-01-14T08:22:21Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"linux/amd64"}

Now expose the app and port-forward to it:

$ kubectl expose pod alpaca-prod
$ kubectl port-forward alpaca-prod 48858:8080

Now switch to terminal 2 and hit the app through the port-forwarded tunnel:

curl http://localhost:48858/

Back to Terminal 1:

Handling connection for 48858
E0114 14:08:58.698803   17224 portforward.go:406] an error occurred forwarding 48858 -> 8080: error forwarding port 8080 to pod c5993e2de9902e4bb3fe8c579d8c41613fa34af5b67b6ecdbeaab5f4521c8574, uid : unable to do port forwarding: socat not found
E0114 14:08:58.699114   17224 portforward.go:234] lost connection to pod

Result

See above

Expected Behavior

Curl should dump a bunch of html output

Additional Information

No response

@ericpromislow ericpromislow added the kind/bug Something isn't working label Jan 14, 2022
@ericpromislow ericpromislow changed the title kubectl port-forwarding fails during use: socat missing on VM kubectl port-forwarding fails during use with moby: socat missing on VM Jan 14, 2022
@gaktive gaktive added this to the v1.0.0 milestone Jan 18, 2022
@ericpromislow
Copy link
Contributor Author

Notes on Windows:

  1. Running both kubectl port-forward and curl in Windows Powershell terminals: works
  2. Running kubectl port-forward in Windows Powershell, curl in Ubuntu/WSL: curl fails to connect to localhost:48858 fails as expected
  3. Running both in Ubuntu/WSL: works

Verified that we're running moby, not containerd.

@gaktive gaktive modified the milestones: v1.0.0, v1.1.0 Jan 19, 2022
@3r1co
Copy link

3r1co commented Jan 19, 2022

For some strange reason, sudo and apk are missing in my Rancher Desktop VM, but I managed to get around this with the following command:

docker run --rm -it -v /usr/bin:/usr/bin -v /usr/lib:/usr/lib alpine apk add socat

I'm also using Windows 10 with WSL2.

Maybe that helps someone having the same issue, but having socat as part of the base image would be really appreciated :-)

@jandubois
Copy link
Member

having socat as part of the base image would be really appreciated

Will be fixed when #1280 is merged; should be in the 1.0.0 final release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants