Search code examples
postgresqldockerkubernetesbitnami

Kubernetes NodePort not accesible from outside


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 

Solution

  • 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