skip to Main Content

I’m trying to use the latest bitnami postgres chart to deploy postgres to a local kubernetes cluster (mac os, docker desktop 4.4.2, kubernetes 1.22.5):
https://github.com/bitnami/bitnami-docker-postgresql

I have set the node port:

primary:
  service:
    # Kubernetes Service type
    type: NodePort
    nodePorts:
      # Node port for PostgreSQL
      postgresql: '30000'

the service is visible:

NAME                             TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
service/postgres-nodeport      NodePort    10.111.195.149   <none>        5432:30000/TCP   9m56s

but I cant access it from outside, eg:

psql -h localhost -p 30000 -U myusername -d mydatabase

but I think it is configured correctly, because when I execute port-forward postgres is available:

kubectl port-forward pod/postgres-nodeport-0 30000:5432 

4

Answers


  1. Chosen as BEST ANSWER

    I found a solution: You need to set the port to higher than 30000, e.g. 30001 but its strange, because earlier it worked with port 30000, and the documentation says that the port range is 30000-32767


  2. Nodeport only exposes the service on the nodes at the specified port. It does not expose it to the public. You need to configure ingress or load balancer to expose the service to the outside world.

    Login or Signup to reply.
  3. you need to call with node ip.
    The format should be NodeIP of the Node where you are running your pods and the NodePort. Ref

    The Template to call NodePort service from outside the cluster is like this.

    <NodeIP>:<NodePort>
    

    Try this one:

    psql -h 192.168.65.4 -p 30000 -U myusername -d mydatabase
    
    Login or Signup to reply.
  4. The Docker Desktop CINC has the vpnkit-controller so if you set a service to use a LoadBalancer it exposes it via your local machine:

    primary:
        service: 
          type: "LoadBalancer"
    

    It is also assigned a random NodePort but the vpnkit will expose the default port of 5432 on localhost.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search