postgresqlkubernetes

access postgres in kubernetes from an application outside the cluster


Am trying to access postgres db deployed in kubernetes(kubeadm) on centos vms from another application running on another centos vm. I have deployed postgres service as 'NodePort' type. My understanding is we can deploy it as LoadBalancer type only on cloud providers like AWS/Azure and not on baremetal vm. So now am trying to configure 'ingress' with NodePort type service. But am still unable to access my db other than using kubectl exec $Pod-Name on kubernetes master.

My ingress.yaml is

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: postgres-ingress
spec:
  backend:
    serviceName: postgres
    servicePort: 5432

which does not show up any address as below

NAME                    HOSTS   ADDRESS    PORTS   AGE
postgres-ingress        *                  80      4m19s

am not even able to access it from pgadmin on my local mac. Am I missing something?

Any help is highly appreciated.


Solution

  • Ingress won't work, it's only designed for HTTP traffic, and the Postgres protocol is not HTTP. You want solutions that deal with just raw TCP traffic: