pkdone / gke-mongodb-demo

Demo project showing how to deploy MongoDB on the Google Container Engine (GKE) with Kubernetes
MIT License
97 stars 39 forks source link

Exposing this for external services to use? #8

Open pvsousalima opened 6 years ago

pvsousalima commented 6 years ago

I am trying to expose it for external services to connect the replicated cluster, how do I make it via LoadBalancer?

PavelYarysh commented 6 years ago

I have the same question. Any solutions?

pvsousalima commented 6 years ago

Yes, I was able to expose one service but I didn't use shards or anything, just a plain mongodb instance. I am still going to make more experiments on the matter so I can test it

PavelYarysh commented 6 years ago

@pvsousalima that is cool. I am trying to expose it via LoadBalancer. I am not sure how to manage the secondary instances. Do I need to create services for all of them and manually choose the connection. Or something else.

caiobegotti commented 6 years ago

I had the same problem today when a developer needed to debug a problem in it but didn't have access to the cluster. For the life of me I couldn't find a way to expose the statefulset externally as apparently it's by design that a headless service won't be reacheable from outside the cluster. For a ad-hoc one-off debug session maybe exposing a single mongodb-0 pod (the primary, if possible) does the trick, but for more complex debugging/issues having a way to reach the main service IP of the statefulset and all its replicas would be ideal, so we could use the whole dynamics of master and slaves & data replication from outside the cluster.