掌舵Postgres连接-无法连接

时间:2020-05-10 15:23:04

标签: database postgresql kubernetes kubernetes-helm camunda

我已经在github上上传了一些代码:https://github.com/darkcloudi/helm-camunda-postgres

运行以下命令将部署两个图表(请注意,该集合是允许部署postgres db所必需的,默认情况下,我已将其禁用,因为camunda带有自己的数据库,因此我尝试将其配置为使用postgres):

helm install dev ./camunda-install --set tags.postgres=true

您会看到一切看起来不错:

NAME                              READY   STATUS      RESTARTS   AGE
pod/dev-camunda-67f487dcd-wjdfr   1/1     Running     0          36m
pod/dev-camunda-test-connection   0/1     Completed   0          45h
pod/postgres-86c565898d-h5tf2     1/1     Running     0          36m

NAME                   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
service/dev-camunda    NodePort    10.106.239.96    <none>        8080:30000/TCP   36m
service/dev-postgres   NodePort    10.108.235.106   <none>        5432:30001/TCP   36m
service/kubernetes     ClusterIP   10.96.0.1        <none>        443/TCP          4d19h

如果我使用10.108.xx ip或minikube ip 192.168.64.2,在下面也遇到相同的错误,我可以使用http://camunda.minikube.local/http://192.168.64.2:30000/连接到tomcat,所以想知道我可能在哪里尝试连接到postgres时出错。

kubectl exec -it postgres-86c565898d-h5tf2 --  psql -h 10.108.235.106 -U admin --password -p 30001 camunda
Password:

psql:错误:无法连接到服务器:无法连接到服务器:连接超时 服务器是否在主机“ 10.108.235.106”上运行并接受 端口30上的TCP / IP连接

kubectl describe svc dev-postgres
Name: dev-postgres
Namespace: default
Labels: app.kubernetes.io/managed-by=Helm
name=dev-postgres
Annotations:  meta.helm.sh/release-name: dev
meta.helm.sh/release-namespace: default
Selector:   app=dev-postgres,name=dev-postgres
Type: NodePort
IP:  10.108.235.106
Port:      postgres-http  5432/TCP
TargetPort:   5432/TCP
NodePort: postgres-http  30001/TCP
Endpoints:   <none>
Session Affinity:  None
External Traffic Policy:  Cluster
Events: <none>

https://github.com/darkcloudi/helm-camunda-postgres/blob/master/camunda-install/charts/postgres/templates/postgres.yaml

1 个答案:

答案 0 :(得分:1)

由于要从群集中访问它,因此应使用ClusterIP 10.108.235.106和端口5432

如果要从群集外部访问它,则可以使用节点IP 192.168.64.2 and NodePort 30001

端口30001在节点VM上侦听,容器在端口5432上侦听。因此,您无法从群集内的端口30001访问它。

编辑:

该服务上的Endpoints为空。这是因为服务上的标签选择器正在选择带有标签app=dev-postgres,name=dev-postgres的广告连播,但广告连播没有该标签。