KongIngress admin cannot connect with postgresql

Thank you for your time to read my question.
I just install kubernetes in my local cluster and install kongIngress by kong-dist-kubernetes.However when I curl $(kong_admin_ip),it returns like this:

HTTP/1.1 500 Internal Server Error
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 42
Content-Type: application/json; charset=utf-8
Date: Tue, 27 Aug 2019 08:49:57 GMT
Server: kong/1.3.0

{
    "message": "An unexpected error happened"
}

And when I curl $(kong_admin_ip)/status,it returns like this:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 962
Content-Type: application/json; charset=utf-8
Date: Tue, 27 Aug 2019 08:51:34 GMT
Server: kong/1.3.0

{
    "database": {
        "reachable": false
    }, 
...

Then I kubectl log kong-control-plane-7dc44c48c9-6r74q.It said:

 2019/08/27 09:33:07 [error] 31#0: *113661 [lua] kong.lua:151: fn(): failed to connect to PostgreSQL during /status endpoint check:
 [PostgreSQL error] [cosocket] DNS resolution failed: dns server error: 3 name error. Tried: 
["(short)postgres.kong.svc:(na) - cache-miss",
"postgres.kong.svc.kong.svc.cluster.local.:33 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.svc.cluster.local.:33 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.cluster.local.:33 - cache-hit/stale/scheduled/dns client error: 101 empty record received",
"postgres.kong.svc.localdomain:33 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc:33 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.kong.svc.cluster.local.:1 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.svc.cluster.local.:1 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.cluster.local.:1 - cache-hit/stale/scheduled/dns client error: 101 empty record received",
"postgres.kong.svc.localdomain:1 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc:1 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.kong.svc.cluster.local.:5 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.svc.cluster.local.:5 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.cluster.local.:5 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc.localdomain:5 - cache-hit/stale/scheduled/dns server error: 3 name error",
"postgres.kong.svc:5 - cache-hit/stale/scheduled/dns server error: 3 name error"], client: 172.17.3.1, server: kong_admin, request: "GET /status HTTP/1.1", host: "172.17.3.5:8001"
172.17.3.1 - - [27/Aug/2019:09:33:07 +0000] "GET /status HTTP/1.1" 200 962 "-" "kube-probe/1.14" 

I thought it may result from the error of kube-dns,however when I check ,it returns like this:

/ # nslookup postgres.kong.svc.cluster.local
nslookup: can't resolve '(null)': Name does not resolve

Name:      postgres.kong.svc.cluster.local
Address 1: 10.68.221.212 postgres.kong.svc.cluster.local

Maybe it is a stupid question,but I cannot find the answer by myself.Thank you for your help again.

dubug with kube-debugger

When I debug pod postgres and kong-control-plane by kube-debugger,I find it that when I curl postgres.kong.svc.cluster.local:5432,I can tcpdump packages in pod postgres,but I cannot tcpdump packages for port 5432 usually.

Could you share the manifest that you are using to install and run Kong?

Have you whitelisted your public ip address on Postgres security settings?

Thank you for your reply.And do you mean that:

 # install kong 
 $ make run_postgres

kubectl apply -f kong-namespace.yaml
namespace/kong unchanged
./setup_certificate.sh
Generating a 2048 bit RSA private key
......+++
..........................+++
writing new private key to 'privkey.pem'
-----
certificatesigningrequest.certificates.k8s.io/kong-control-plane.kong.svc created
certificatesigningrequest.certificates.k8s.io/kong-control-plane.kong.svc approved
Error from server (AlreadyExists): secrets "kong-control-plane.kong.svc" already exists
make: [k8s_setup] 错误 1 (忽略)
kubectl -n kong apply -f postgres.yaml
service/postgres unchanged
replicationcontroller/postgres unchanged
kubectl -n kong apply -f kong-control-plane-postgres.yaml
serviceaccount/kong unchanged
role.rbac.authorization.k8s.io/kong unchanged
rolebinding.rbac.authorization.k8s.io/kong unchanged
deployment.extensions/kong-control-plane unchanged
service/kong-control-plane unchanged
kubectl -n kong apply -f kong-ingress-data-plane-postgres.yaml
deployment.extensions/kong-ingress-data-plane unchanged
service/kong-ingress-data-plane unchanged

 #run kong
 $ kubectl get pod -n kong -o wide
NAME                                      READY   STATUS    RESTARTS   AGE   IP           NODE           NOMINATED NODE   READINESS GATES
kong-control-plane-7dc44c48c9-6r74q       1/1     Running   0          17h   172.17.3.5   172.20.10.11   <none>           <none>
kong-ingress-data-plane-9bdd45b56-srr9r   1/1     Running   0          17h   172.17.2.4   172.20.10.10   <none>           <none>
postgres-wbrhn                            1/1     Running   0          17h   172.17.2.3   172.20.10.10   <none>           <none>
$ kubectl get svc -n kong -o wide
NAME                      TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                         AGE   SELECTOR
kong-control-plane        NodePort    10.68.152.65    <none>        8001:33267/TCP,443:22316/TCP    17h   app=kong-control-plane
kong-ingress-data-plane   NodePort    10.68.96.157    <none>        8000:37465/TCP,8443:21882/TCP   17h   app=kong-ingress-data-plane
postgres                  ClusterIP   10.68.221.212   <none>        5432/TCP                        17h   app=postgres

Thank you for your reply.And I have trid to connect to postgresql in my master node:

 $ psql -U kong -h 10.68.221.212 -p 5432

It work well.


© 2018 Kong Inc.    Terms  •  Privacy  •  FAQ