postgres-operator: Load Balancer for PG Master missing Selectors

Problem

When deploying a new cluster using the operator, I dee that the cluster comes up and spilo roles are assigned to them master and replica node(s).

I also see the load balancer for the replica nodes come up.

However, the load balancer for the master node gets created but never gets a external IP. Looking at the ressource created, I see that the LB is missing a “selector” in it’s spec. Editing the ressource online and adding the selector for the master spilo-role “fixes” the load balancer.

I’ve looked at the code in k8res.go and indeed the selectors are only added for the replica load balancer there.

Am I missing something?

Versions Used

I’m testing the operator on GKE running 4 nodes and kubernetes 1.10. I’m using the current master of the postgres-operator.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 1
  • Comments: 19 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@CarlQLange I’m using this workaround:

kubectl port-forward $(kubectl get pod -l cluster-name=foo-db,spilo-role=master -o jsonpath='{.items[0].metadata.name}') 15432:5432

This also doesn’t allow allow to reliably connect from the outside with port-forward:

❯ k port-forward service/foo-main 5432
error: cannot attach to *v1.Service: invalid service 'foo-main': Service is defined without a selector

I understood the rationale behind the decision, so just pointing the problem out.

Why is this ticket still open if this is intended behavior?

There are not supposed to be selectors on the master service. Assigning and removing endpoints is done by Patroni. This is intentional to not end up having two pods in there, which can happen.

I am running into this problem currently. How do I port-forward given this error? I don’t want to set up an Ingress.

> kubectl port-forward service/production-geodb 5432:5432
error: cannot attach to *v1.Service: invalid service 'production-geodb': Service is defined without a selector