News for hackers. Stuff that matters.
Re:Deploying PostgreSQL Clusters Using StatefulSets by crb on Sunday February 26, 2017 @02:43PM (#13739338)
If your pattern requires you to connect to etcd, then you're not taking the best advantage of Kubernetes.

Yes, you can connect to an etcd instance outside of Kubernetes, or deploy etcd on Kubernetes. CoreOS developed the etcd operator for the purposes of self-hosting the system KV store, but you can of course run a "user" etcd.

A better pattern is relying on the objects provided by Kubernetes, which are themselves backed by a lock service (which happens to be etcd, but that's an implementation detail you shouldn't worry about.)

You could, for example, use an Annotation on an object to do leader election. Look at how HA masters are implemented on Kubernetes, for example:

https://github.com/kubernetes/kubernetes/blob/master/pkg/cli...

Re:Deploying PostgreSQL Clusters Using StatefulSets by achanda358 on Sunday February 26, 2017 @03:46PM (#13739753)
That's a great point. But doesn't this make it mandatory for the applications to use Go? It would have been more useful if there was a REST interface for leader election.
Re:Deploying PostgreSQL Clusters Using StatefulSets by crb on Sunday February 26, 2017 @03:53PM (#13739791)
Not at all - it's just a language for which there is a Kubernetes client. The API is 100% REST. We have a Python library underway also: https://github.com/kubernetes-incubator/client-python
Re:Deploying PostgreSQL Clusters Using StatefulSets by achanda358 on Sunday February 26, 2017 @07:12PM (#13740862)
Right, but I couldn't find a REST API for leader election. If my app is in Go, I can use the leaderelection package here https://github.com/kubernetes/kubernetes/blob/master/pkg/cli.... But if my app is in Python, I won't be able to use that package. In that case I'd need to use etcd or zookeeper on top of k8s. Am I missing something?
Re:Deploying PostgreSQL Clusters Using StatefulSets by crb on Monday February 27, 2017 @05:26AM (#13743217)
You can reimplement that logic in Python. There's nothing magic about it: you can see in https://github.com/kubernetes/kubernetes/blob/master/pkg/cli... that it just uses a Kubernetes annotation.

There's some more information (and a sidecar pod prebaked) at http://blog.kubernetes.io/2016/01/simple-leader-election-wit...

Re:Deploying PostgreSQL Clusters Using StatefulSets by CyberDem0n on Monday February 27, 2017 @08:10AM (#13743893)
Yes, one can reimplement it in Python, but don't forget:

// This implementation does not guarantee that only one client is acting as a // leader (a.k.a. fencing). A client observes timestamps captured locally to // infer the state of the leader election. Thus the implementation is tolerant // to arbitrary clock skew, but is not tolerant to arbitrary clock skew rate.

Re:Deploying PostgreSQL Clusters Using StatefulSets by alexk on Sunday February 26, 2017 @05:15PM (#13740308)
makes sense, this was written before TPR though, so there is a room for improvement.