首页 > 解决方案 > Kubernetes Pod (Plex) 上的连接被拒绝

问题描述

在裸机三节点本地集群上设置 Kubernetes。

丛部署:

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

部署很愉快。波德很高兴。

我尝试通过 NodePort、ClusterIP、HostPort、LoadBallancer (metalDB) 公开 Pod,并且在每个排列中,我在浏览器中或通过 Curl 收到连接被拒绝错误。

节点端口示例:

$ 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

我在这里想念什么?

标签: kubernetesplex

解决方案


因此,只有最后一个可能是正确的。该输出中的 IP 是集群 IP,通常(尽管并非总是如此,这取决于您的 CNI 插件和配置)只能在集群内部从其他 pod 访问。NodePort 意味着该服务也可以在任何节点 IP 上的该端口上访问。不过,这可能会被您节点上的防火墙阻止,因此请检查一下。还要确保这是一个有效的节点 IP。


推荐阅读