<blockquote>
<p>in kubernetes i have postgres as a stateful set and i have it defined as service postgres then i want to expose it as an ingress.
i have changed type from clusterip to NodePort of the service and i have created ingress for postgres like below</p>
</blockquote>
<pre><code>kind: Ingress
metadata:
  name: postgres
  namespace: postgres

  annotations:
    alb.ingress.kubernetes.io/group.name: eks-dev-test-postgres-group
    alb.ingress.kubernetes.io/listen-ports: '[{&quot;HTTP&quot;:5432}]'
    alb.ingress.kubernetes.io/load-balancer-name: eks-dev-test-alb-postgres
    alb.ingress.kubernetes.io/scheme: internal
    alb.ingress.kubernetes.io/tags: Environment=dev-test,Team=devops


spec:
  ingressClassName: alb
  rules:
    - host: postgres.test.XXXXXX.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: postgres
                port:
                  number: 5432
</code></pre>
<blockquote>
<p>i use alb ingress controller to create/manage  ingress</p>
</blockquote>
<blockquote>
<p>here in AWS, i have created new load balancer name : eks-dev-test-alb-postgres
region : us-east-1
load balancer arn: arn:aws:elasticloadbalancing:us-east-1:XXXXX:loadbalancer/app/eks-dev-test-alb-postgres/XXXXX
and security group inbound rules updated to 5432 opens to everyone
this vpc is secured by aws vpn and i`m connected to vpn</p>
</blockquote>
<blockquote>
<p>i turned off ssl in pgadmin and attached the snip of error</p>
</blockquote>
<blockquote>
<p>in DB weaver, when i<code>m trying to TEST CONNECTION in universal database management tool (DBeaver) i</code>m facing &quot;An error occurred while setting up the SSL connection&quot;.</p>
</blockquote>
<p><a href="https://i.stack.imgur.com/fO07e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fO07e.png" alt="enter image description here" /></a></p>
<p>ANSWER:</p>
<blockquote>
<p>Service type should be : LoadBalancer</p>
</blockquote>
<blockquote>
<p>in service annotations : nlb and internal should add like below</p>
</blockquote>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: postgres-postgresql-external
  labels:
    app: postgresql
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-internal: &quot;true&quot;
    service.beta.kubernetes.io/aws-load-balancer-type: nlb
spec:
  type: LoadBalancer
  ports:
  - name: postgresql
    port: 5432
    targetPort: postgresql
  selector:
    app: postgresql
    release: &quot;postgres&quot;
  loadBalancerSourceRanges:
  - &quot;172.16.0.0/16&quot;
</code></pre>
<hr />
<p>REF link: <a href="https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.5/guide/service/nlb/" rel="nofollow noreferrer">https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.5/guide/service/nlb/</a></p>
<blockquote>
<p>Network Load Balancer (NLB) doesnt have SG.</p>
</blockquote>
<blockquote>
<p>In EC2 Instance Security Group need to open as 5432</p>
</blockquote>
<p>REF link: <a href="https://repost.aws/questions/QUuueXAi20QuisbkOhinnbzQ/aws-nlb-security-group" rel="nofollow noreferrer">https://repost.aws/questions/QUuueXAi20QuisbkOhinnbzQ/aws-nlb-security-group</a></p>
<blockquote>
<p>Check telnet</p>
</blockquote>
<blockquote>
<p>then disable SSL in pgamin while creating connection</p>
</blockquote>
<blockquote>
<p>Test the connection</p>
</blockquote>

dheeraj
<p>Ingress only works for HTTP traffic. You will not able to expose TCP/5432 using ingress.</p>
<p>Consider creating a service of type LoadBalancer with the appropriate annotations by following the AWS Load Balancer Controller documentation:</p>
<p><a href="https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.5/guide/service/nlb/" rel="nofollow noreferrer">https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.5/guide/service/nlb/</a></p>
