[英]Postgres+django on kubernetes: django.db.utils.OperationalError: could not connect to server: Connection timed out
My Django app can't connect to the Postgres server on Kubernetes.我的 Django 应用程序无法连接到 Kubernetes 上的 Postgres 服务器。 All other pods are able to connect to this Postgres server and creds are valid as well, any idea why not this Django app
所有其他 pod 都能够连接到此 Postgres 服务器,并且凭据也有效,知道为什么不使用此 Django 应用程序
django.db.utils.OperationalError: could not connect to server: Connection timed out Is the server running on host "postgres-postgresql" (10.245.56.118) and accepting TCP/IP connections on port 5342?
django.db.utils.OperationalError:无法连接到服务器:连接超时服务器是否在主机“postgres-postgresql”(10.245.56.118)上运行并接受端口 5342 上的 TCP/IP 连接?
Picture of the problem.问题的图片。 I login into the django app container and tried to connect via Django's data access layer and psql.
我登录到 django 应用程序容器并尝试通过 Django 的数据访问层和 psql 进行连接。 Only psql is working without any problems
只有 psql 工作没有任何问题
postgres: postgres:
https://github.com/cetic/helm-postgresql https://github.com/cetic/helm-postgresql
Kubernetes: Kubernetes:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
githubdir.service: valnet
name: valnet
spec:
selector:
matchLabels:
app: valnet
replicas: 1
strategy:
type: Recreate
template:
metadata:
creationTimestamp: null
labels:
app: valnet
spec:
containers:
- args:
env:
- name: VALNET_DATABASE_USER
value: "postgres"
- name: VALNET_DATABASE_PASSWORD
value: "gdrBP9xxDZ"
- name: VALNET_DATABASE_HOST
value: "postgres-postgresql"
- name: VALNET_DATABASE_PORT
value: "5342"
image: donutloop/valnet:v0.3.0
name: valnet
ports:
- containerPort: 8000
resources: {}
restartPolicy: Always
That chart configured Postgres to listen on port 5432. You tried to connect to port 5342. Those are different.该图表将 Postgres 配置为侦听端口 5432。您尝试连接到端口 5342。这些是不同的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.