On Minikube; After port forwarding curl is giving empty response

1/4/2022

I am running minikube cluster and have pods running with replicaSet as 3. They expose a web interface. I have created all 3 services ( NodePort, LoadBalancer, ClusterIP ) with same selector so as to map to same 3 pods.

curl MiniKubeNodeIP:PortOfService  # gives html output which is good.

As I am running minikube on VM; I want this service to be accessible from outside VM. Its on-prem solution and no cloud. Hence, tried using port-forwarder with all 3 services which starts fine but gives following error moment I send a curl request:

admin@ubuntu-4:~$ k port-forward service/xyz :7000
Forwarding from 127.0.0.1:35093 -> 7000
Forwarding from [::1]:35093 -> 7000
Handling connection for 35093
E0104 18:00:06.504088   49711 portforward.go:406] an error occurred forwarding 35093 -> 7000: error forwarding port 7000 to pod eaff29997ebed0b9141deda10fc6466fce93c9f4f85b50f2f2d2d62f50a164
f7, uid : exit status 1: 2022/01/04 18:00:06 socat[45373] E connect(5, AF=2 127.0.0.1:7000, 16): Connection refused
E0104 18:00:06.504445   49711 portforward.go:234] lost connection to pod

I am assuming big hex string printed is UID of pod; but I grep and I have no such pod running in any namespace ! I feel this is the root cause that request is going to some dummy pod ! Manual of port forwarding says " The forwarding session ends when the selected pod terminates" and in my case also pod is getting terminated. Curl request is:

admin@ubuntu-4:~$ curl localhost:35093
curl: (52) Empty reply from server

Pod description is:

Name:         yb-master-0
Namespace:    default
Priority:     0
Node:         minikube/192.168.49.2
Start Time:   Tue, 04 Jan 2022 12:55:48 +0000
Labels:       app=yb-master
              controller-revision-hash=yb-master-7555658d4d
              statefulset.kubernetes.io/pod-name=yb-master-0
Annotations:  <none>
Status:       Running
IP:           172.17.0.6
IPs:
  IP:           172.17.0.6
Controlled By:  StatefulSet/yb-master
Containers:
  yb-master:
    Container ID:  docker://8579b43d4ba9dfe727e2d15da6c367532c5e27bf67cdf6a7fb43b64da75d15a1
    Image:         yugabytedb/yugabyte:latest
    Image ID:      docker-pullable://yugabytedb/yugabyte@sha256:3a7780669f13b8122662b9967aca47c7fac3cbc681f977cbe26724d069f3e72f
    Ports:         7000/TCP, 7100/TCP
    Host Ports:    0/TCP, 0/TCP
    Command:
      /home/yugabyte/bin/yb-master
      --fs_data_dirs=/mnt/data0
      --rpc_bind_addresses=$(POD_NAME).yb-masters.$(NAMESPACE).svc.cluster.local:7100
      --server_broadcast_addresses=$(POD_NAME).yb-masters.$(NAMESPACE).svc.cluster.local:7100
      --use_private_ip=never
      --master_addresses=yb-master-0.yb-masters.$(NAMESPACE).svc.cluster.local:7100,yb-master-1.yb-masters.$(NAMESPACE).svc.cluster.local:7100,yb-master-2.yb-masters.$(NAMESPACE).svc.cluster
.local:7100
      --enable_ysql=true
      --replication_factor=3
      --logtostderr
    State:          Running
      Started:      Tue, 04 Jan 2022 15:43:28 +0000
    Last State:     Terminated
      Reason:       Error
      Exit Code:    143
      Started:      Tue, 04 Jan 2022 12:56:45 +0000
      Finished:     Tue, 04 Jan 2022 15:32:11 +0000
    Ready:          True
    Restart Count:  1
    Environment:
      GET_HOSTS_FROM:  dns
      POD_IP:           (v1:status.podIP)
      POD_NAME:        yb-master-0 (v1:metadata.name)
      NAMESPACE:       default (v1:metadata.namespace)
    Mounts:
      /mnt/data0 from datadir (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-kz7mv (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  datadir:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  datadir-yb-master-0
    ReadOnly:   false
  kube-api-access-kz7mv:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:                      <none>

Any help would be appreciated.

-- Deepak Singhal
kubernetes
kubernetes-ingress
minikube

0 Answers