k3s kubectl port-forward fails due to missing socat

shaduw

Cadet
Joined
Jun 24, 2023
Messages
2
Hi everyone,
I'm unable to port-forward to a specific service managed by Kubernetes/k3s. The port forwarding starts with the following message:
k3s kubectl port-forward service/argo-cd-argocd-server -n argo-cd 8080:443 --address=0.0.0.0
Forwarding from 0.0.0.0:8080 -> 8080
Handling connection for 8080
However, once I try to connect to it it stops with the following error:
E0624 20:29:35.327346 333443 portforward.go:406] an error occurred forwarding 8080 -> 8080: error forwarding port 8080 to pod 999d99b3979fd837fc5a682dc502d3898f3cb1497ccae8204a1008f794cad842, uid : unable to do port forwarding: socat not found
E0624 20:29:35.327511 333443 portforward.go:234] lost connection to pod
This specific port-forward is happening on the Truenas scale server (version 22.12.3). I get the same error when running this on any other machine towards this host (I made Kubernetes accessible from the outside).

I'm using the kubectl version that's provided by k3s:
clientVersion:
buildDate: "2023-06-12T20:04:38Z"
compiler: gc
gitCommit: 9afcd6b939a7d71f4a29ef382f83942c4417322a
gitTreeState: dirty
gitVersion: v1.25.3+k3s-9afcd6b9-dirty
goVersion: go1.19.8
major: "1"
minor: "25"
platform: linux/amd64
kustomizeVersion: v4.5.7
serverVersion:
buildDate: "2023-06-12T20:04:38Z"
compiler: gc
gitCommit: 9afcd6b939a7d71f4a29ef382f83942c4417322a
gitTreeState: dirty
gitVersion: v1.25.3+k3s-9afcd6b9-dirty
goVersion: go1.19.8
major: "1"
minor: "25"
platform: linux/amd64
How can I port-forward to services in my cluster?
 

shaduw

Cadet
Joined
Jun 24, 2023
Messages
2
For anyone that struggles with the same problem. I managed to resolve it by copying `socat` from a `debian:11-slim` container (`apt update && apt install socat`). I copied the `socat` binary to the Truenas host: `/usr/local/bin/socat`. Port forwarding now works as expected.
 
Top