Unable to connect to postgres backend using hostname
I have 2 postgres service (postres-1 & postgres-2) svc name respectively with port 5432
as per the document Exposing a TCP Service - Kong Ingress Controller - v2.5.x | Kong Docs I have exposed 5432 kong service initially and added env variable KONG_STREAM_LISTEN: 0.0.0.0:5432 ssl
then applied the below config
apiVersion: configuration.konghq.com/v1beta1
kind: TCPIngress
metadata:
name: postres
annotations:
kubernetes.io/ingress.class: kong
spec:
rules:
- host: postgres1.local
port: 5432
backend:
serviceName: postres-1
servicePort: 5432
- host: postgres2.local
port: 5432
backend:
serviceName: postres-2
servicePort: 5432
but im unable to reach postgres pod using the hostname provided. Connection is getting closed immediately
tried single postgres with hostname still the same results
apiVersion: configuration.konghq.com/v1beta1
kind: TCPIngress
metadata:
name: postgres
annotations:
kubernetes.io/ingress.class: kong
spec:
rules:
- host: example1.local
port: 5432
backend:
serviceName: postgres
servicePort: 5432
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres
env:
- name: POSTGRES_PASSWORD
value: password
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 5432
---
apiVersion: v1
kind: Service
metadata:
name: postgres
spec:
selector:
app: postgres
ports:
- port: 5432
targetPort: 5432
protocol: TCP
Getting this below logs when trying to connect
192.168.65.3 [13/Sep/2022:04:40:44 +0000] TCP 500 0 0 0.001
2022/09/13 04:40:44 [error] 1114#0: *9202 stream [lua] handler.lua:1215: before(): no Route found with those values while prereading client data, client: 192.168.65.3, server: 0.0.0.0:5432
traines
September 29, 2022, 12:12am
4
Are you indeed using TLS? Hostnames route via inspecting SNI information during a TLS handshake. If you’re just using plain TCP, you’ll need to remove the host value and rely on the port alone.