裸机三节点本地集群上的 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,LoadBalancer(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
我在这里错过了什么?
所以在那些中,只有最后一个可能是对的。该输出中的 IP 是集群 IP,通常(尽管并非总是如此,这取决于您的 CNI 插件和配置(只能在集群内部从其他 Pod 访问。NodePort 意味着该服务也可以在任何节点 IP 上的该端口上访问。不过,这可能会被节点上的防火墙阻止,因此请检查一下。还要确保这是有效的节点 IP。