Closed zenmaster24 closed 3 years ago
Thank you for your message.
That feature was not implemented. The person who raised the issue didn't reply that our recommendation. And consequently we didn't implement it.
Hi,
I am trying to expose kubegres to traffic external to the cluster by following the guidance provided here and have created a service before creating the resource
postgres
of kind kubegres.I have set the service to be the below:
apiVersion: 1 kind: Service metadata: name: postgres namespace: kubegres spec: type: NodePort selector: app: postgres replicationRole: primary ports: - port: 5432 targetPort: 5432 nodePort: 30432 protocol: TCP
I can't seem to connect to the pod via
<NODEIP>:30432
however. I can see in the pod logs of the primary that thedatabase system is ready to accept connections
. If I use kubectl port forwarding I can connect an SQL client and run queries against it like create db and see some relevant output when tailing the pod logs, so I know its up and responding.Am I missing something? How do I expose this db to external traffic?
NB: If it matters, I have replicas set to 1 for testing
I was able to make it work like this:-
apiVersion: v1 kind: Service metadata: labels: app: mydb replicationRole: primary name: mydb-np namespace: mynamespace ownerReferences:
kubectl edit svc primary-service-name --> note down the UID inside "ownerReferences" and use that for your node port service.
You can do the same thing for replica services.
Thank you for those details, it would be helpful for others. If you are happy, I am closing this ticket.
This worked for me without the need to set uid
: https://github.com/reactive-tech/kubegres/issues/44#issuecomment-925567428
Determine the app
label of the Kubegres service:
kubectl describe service ...
Labels: app=mypostgres
replicationRole=primary
Define a NodePort
Service
and use that app
label as the selector:
apiVersion: v1
kind: Service
metadata:
name: postgres-node-port
spec:
type: NodePort
selector:
app: mypostgres
replicationRole: primary
ports:
- port: 5432
targetPort: 5432
nodePort: 30432
protocol: TCP
Hi,
I am trying to expose kubegres to traffic external to the cluster by following the guidance provided here and have created a service before creating the resource
postgres
of kind kubegres.I have set the service to be the below:
I can't seem to connect to the pod via
<NODEIP>:30432
however. I can see in the pod logs of the primary that thedatabase system is ready to accept connections
. If I use kubectl port forwarding I can connect an SQL client and run queries against it like create db and see some relevant output when tailing the pod logs, so I know its up and responding.Am I missing something? How do I expose this db to external traffic?
NB: If it matters, I have replicas set to 1 for testing