High availability issue with rethinkdb cluster in kubernetes

10/21/2015

I'm setting up rethinkdb cluster inside kubernetes, but it doesn't work as expected for high availability requirement. Because when a pod is down, kubernetes will creates another pod, which runs another container of the same image, old mounted data (which is already persisted on host disk) will be erased and the new pod will join the cluster as a brand new instance. I'm running k8s in CoreOS v773.1.0 stable.

Please correct me if i'm wrong, but that way it seems impossible to setup a database cluster inside k8s.

Update: As documented here http://kubernetes.io/v1.0/docs/user-guide/pod-states.html#restartpolicy, if RestartPolicy: Always it will restart the container if exits failure. It means by "restart" that it brings up the same container, or create another one? Or maybe because I stop the pod via command kubectl stop po so it doesn't restart the same container?

-- Quyen Nguyen Tuan
kubernetes
rethinkdb

2 Answers

10/1/2016

Try using PetSets http://kubernetes.io/docs/user-guide/petset/ That allows you to name your (pet) pods. If a pod is killed, then it will come back with the same name.

Summary of the petset feature is as follows.

  • Stable hostname
  • Stable domain name
  • Multiple pets of a similar type will be named with a "-n" (rethink-0, rethink-1, ... rethink-n for example)
  • Persistent volumes
  • Now apps can cluster/peer together

When a pet pod dies, a new one will be started and will assume all the same "state" (including disk) of the previous one.

-- rideswitch
Source: StackOverflow

10/23/2015

That's how Kubernetes works, and other solution works probably same way. When a machine is dead, the container on it will be rescheduled to run on another machine. That other machine has no state of container. Event when it is the same machine, the container on it is created as a new one instead of restarting the exited container(with data inside it).

To persistent data, you need some kind of external storage(NFS, EBS, EFS,...). In case of k8s, you may want to look into this https://github.com/kubernetes/kubernetes/blob/master/docs/design/persistent-storage.md This Github issue also has many information https://github.com/kubernetes/kubernetes/issues/6893

And in deed, that's the way to achieve HA in my opinion. Container are all stateless, they don't hold anything inside them. Any configuration needs for them should be store outside such as using thing like Consul or Etcd. By separating this like this, it's easier to restart a container

-- kureikain
Source: StackOverflow