无法通过客户端工具连接Minikube Kubernetes上的PostgreSQL
PostgreSQL在Minikube Kubernetes集群中外部连接超时问题
已完成的部署与内部连接验证
- 已在Kubernetes上成功部署PostgreSQL,对应的Service信息如下:
postgres NodePort 10.96.66.202 <none> 5432:30030/TCP
- 可通过Pod内部命令正常连接PostgreSQL:
kubectl exec -it postgres-75b8fd84f-gkj6k -- psql -h localhost -U appuser --password -p 5432 appdb
外部连接尝试及失败情况
尝试使用本地客户端工具通过不同方式连接时,均出现超时错误:
方式1:Service集群IP + NodePort
host=$(minikube ip) 192.168.49.2 port=$(kubectl get service postgres -o jsonpath='{.spec.ports[0].nodePort}') 30030 $ psql -h 10.96.66.202 -U appuser --password -p 30030 appdb Password: psql: error: could not connect to server: Connection timed out (0x0000274C/10060) Is the server running on host "10.96.66.202" and accepting TCP/IP connections on port 30030?
方式2:Minikube节点IP + NodePort
$ psql -h 192.168.49.2 -U appuser --password -p 30030 appdb Password: psql: error: could not connect to server: Connection timed out (0x0000274C/10060) Is the server running on host "192.168.49.2" and accepting TCP/IP connections on port 30030?
方式3:Service集群IP + 容器端口
$ psql -h 10.96.66.202 -U appuser --password -p 5432 appdb Password: psql: error: could not connect to server: Connection timed out (0x0000274C/10060) Is the server running on host "10.96.66.202" and accepting TCP/IP connections on port 5432?
内容的提问来源于stack exchange,提问作者user19930511
相关产品推荐
相关产品推荐

