Why can't I connect to pods through the port-forwarder?

10/20/2019

UPDATE:

solved this by installing socat -

   sudo apt-get -y install socat

I'm trying to connect to pod I run within minikube through port-forwarder from another terminal, but get some error.

My kubectl version -

Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3", GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08-19T11:13:54Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}

Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.2", GitCommit:"f6278300bebbb750328ac16ee6dd3aa7d3549568", GitTreeState:"clean", BuildDate:"2019-08-05T09:15:22Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}

The YML file content -

apiVersion: v1
kind: Pod
metadata:
  name: kubia-manual
spec:
  containers:
  - image: luksa/kubia
    name: kubia
    ports:
    - containerPort: 8080
      protocol: TCP

I ran -

kubectl create -f kubia-manual.yaml

kubectl port-forward kubia-manual 8888:8080

and got -

Forwarding from 127.0.0.1:8888 -> 8080

Forwarding from [::1]:8888 -> 8080

after I'm trying to connect to the pod from another terminal like that -

curl localhost:8888

I get in this terminal

curl: (52) Empty reply from server

And in the second terminal, where I ran the port-forward command I'm getting -

Handling connection for 8888 E1020 14:55:35.817708 7075 portforward.go:400] an error occurred forwarding 8888 -> 8080: error forwarding port 8080 to pod 253ecb3809333d7dbf7c54831ea12e1eee4f43c3107764ea8ad55f0cad06bc2c, uid : unable to do port forwarding: socat not found.

-- nirkov
kubectl
kubernetes
kubernetes-pod
minikube
portforwarding

2 Answers

10/20/2019

I think based on your port-forwarding you should try connecting it on 8888

 curl localhost:8888

It works for me

-- Tushar Mahajan
Source: StackOverflow

10/20/2019

In the end I solved it by installing socat -

   sudo apt-get -y install socat
-- nirkov
Source: StackOverflow