Connection Refused on Kubernetes Pod (Plex)

1/24/2020

Kubernetes setup on a baremetal three node local cluster.

Plex deployment:

kind: Deployment
apiVersion: apps/v1
metadata:
  name: plex
  labels:
    app: plex
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      name: plex
  template:
    metadata:
      labels:
        name: plex
    spec:
      containers:
        - name: plex
          image: plexinc/pms-docker:plexpass
          imagePullPolicy: Always
          ports:
            - containerPort: 32400
              hostPort: 32400
          volumeMounts:
            - name: nfs-plex-meta
              mountPath: "/data"
            - name: nfs-plex
              mountPath: "/config"
      volumes:
      - name: nfs-plex-meta
        persistentVolumeClaim:
          claimName: nfs-plex-meta
      - name: nfs-plex
        persistentVolumeClaim:
          claimName: nfs-plex

Deployment is happy. Pod is happy.

I've tried exposing the Pod via NodePort, ClusterIP, HostPort, LoadBallancer (metalDB) and in every permutation, I get a connection refused error in the browser or via Curl.

NodePort Example:

$ kubectl expose deployment plex --type=NodePort --name=plex
service/plex exposed
$ kubectl describe svc plex
Name:                     plex
Namespace:                default
Labels:                   app=plex
Annotations:              <none>
Selector:                 name=plex
Type:                     NodePort
IP:                       10.111.13.7
Port:                     <unset>  32400/TCP
TargetPort:               32400/TCP
NodePort:                 <unset>  30275/TCP
Endpoints:                10.38.0.0:32400
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>
$ curl 10.111.13.7:32400
curl: (7) Failed to connect to 10.111.13.7 port 32400: Connection refused
$ curl 10.38.0.0:32400
curl: (7) Failed to connect to 10.38.0.0 port 32400: Connection refused
$ curl 192.168.1.11:32400
curl: (7) Failed to connect to 192.168.1.110 port 32400: Connection refused
$ curl 192.168.1.11:30275
curl: (7) Failed to connect to 192.168.1.110 port 30275: Connection refused

What am I missing here?

-- Chase Westlye
kubernetes
plex

1 Answer

1/24/2020

So of those, only the last might be right. The IP in that output is a cluster IP, which usually (though not always, it’s up to your CNI plugin and config) is only accessible inside the cluster from other pods. NodePort means that the service is also reachable on that port on any node IP. This might be getting blocked by a firewall on your node though, so check that. Also make sure that’s a valid node IP.

-- coderanger
Source: StackOverflow