0
votes

I run a local kubernetes cluster (Minikube) and I try to connect pgAdmin to postgresql, bot run in Kubernetes. What would be the connection string? Shall I access by service ip address or by service name? kubectl get service

NAME              TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
dbpostgresql      NodePort    10.103.252.31   <none>        5432:30201/TCP   19m
kubernetes        ClusterIP   10.96.0.1       <none>        443/TCP          3d21h
pgadmin-service   NodePort    10.109.58.168   <none>        80:30200/TCP     40h

kubectl get ingress:

NAME              CLASS    HOSTS   ADDRESS        PORTS   AGE
pgadmin-ingress   <none>   *       192.168.49.2   80      40h

kubectl get pod

NAME                        READY   STATUS    RESTARTS   AGE
pgadmin-5569ddf4dd-49r8f    1/1     Running   1          40h
postgres-78f4b5db97-2ngck   1/1     Running   0          23m

I have tried with 10.103.252.31:30201 but without success.

1
Both pgadmin and postgresql are running inside cluster. Shouldn't it be accessible by ip?csm86
Ah, I got it. Then it should work, yes.Jonas

1 Answers

0
votes

Inside the cluster, services can refer to each other by DNS based on Service object names. So in this case you would use dbpostgresql or dbpostgresql.default.svc.cluster.local as the hostname.