![](/img/trans.png)
[英]Cannot connect to a Mongodb pod in Kubernetes (Connection refused)
[英]Connection Refused on 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
我在這里缺少什么?
所以,只有最后一個可能是正確的。 該輸出中的 IP 是集群 IP,通常(盡管並非總是如此,這取決於您的 CNI 插件和配置)只能在集群內部從其他 pod 訪問。 NodePort 意味着該服務也可以在任何節點 IP 的該端口上訪問。 不過,這可能會被您節點上的防火牆阻止,因此請檢查一下。 還要確保這是一個有效的節點 IP。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.