k3s-io / kine

Run Kubernetes on MySQL, Postgres, sqlite, dqlite, not etcd.
Apache License 2.0
1.49k stars 226 forks source link

Multi-replica Kine #295

Closed buji-code closed 2 months ago

buji-code commented 2 months ago

Hi guys, I'm deploying my in-house multi-control-plane based on vanilla Kubernetes. I thought I could run a Kine container for each control-plane Node, making it fully HA between all apiserver Pods. I notice inconsistent responses when polling the apiserver. This behavior stoped when I scaled my control-plane replicas to 1 (making it a single api-server against a single Kine).

Can Kine run with multiple replicas and ensure correctness at all? If not, does it support a leader-election mechanism?

brandond commented 2 months ago

Yes, you can run multiple instances of Kine against a datastore. This is how K3s works when you point multiple servers at a shared database. Each server runs an instance of Kine against the target database, and each server runs an apiserver that talks to the local kine instance.

It should also work fine to point multiple apiservers at a single kine instance, or multiple apiservers at a pool of kine instances. This is not a model that we use, so it probably sees less testing. If you can reproduce any problems, please open an issue describing specifically what you're seeing, with steps to reproduce.