Question: Is the Kubernetes API strongly consistent?

Hi,

I got a general question regarding the Kubernetes API: Is it strongly consistent or eventual consistent? Are there any partial guarantees (e.g., strongly consistent on same resource type/object, or similar).

To make it specific: If I successfully post a new resource A of type a, and directly query resources of type a afterwards, is it guaranteed that I see A in the response?

Thanks!

The Kubernetes API is using etcd to store cluster data. You can read more about the read consistency of etcd here[1] and here [2]

  1. https://coreos.com/blog/announcing-etcd-3.3
  2. https://github.com/etcd-io/etcd/issues/741
1 Like

You can achieve strong consistency for read-modify-write by using resourceVersion.

Then, if your writer has a side channel to your reader, you can pass over the written version number and watch+block until you see the updated version.

More generally, looking at the whole system: due to the watch+modify pattern, Kubernetes as a whole is eventually consistent - changing your Deployment will not be immediately reflected in the Pod objects, for both unavoidable and intentional reasons

Thank you for your responses!

Most helpful for me was @feloy s answer regarding etcd, which offers sequential consistency.

Which I interpret as: yes.