NiftySoft / k8s-gossipcar

Kubernetes sidecar providing a lightweight eventually-consistent key-value store.
MIT License
1 stars 0 forks source link
key-value-store kubernetes lightweight netty4 rest-api sidecar-container

Gossipcar

Kubernetes-native Volatile Datastore

Gossipcar Logo

GitHub tag MIT Licensed

Travis CI Build Codacy Badge Codacy Badge

A lightweight Kubernetes sidecar for syncing an in-memory key-value store between pods.

But Why?

Not all cluster data requires strong write consistency and high-availability. Sometimes you just want to sync information with peers without taxing cluster resources. This sidecar is built for those use-cases.

  1. Provides a key-value store for syncing arbitrary data (as long as it is a UTF-8 string).
  2. Exposes GET and PUT HTTP endpoints for ease-of-use.
  3. Uses gossip-protocols to perform two-way sync with a random peer.
  4. Built on Netty, a lightweight non-blocking networking library for Java.

How does it work?

The sidecar is installed as a headless Kubernetes service. During sync, each node looks up its list of peers from the service and initiates two-way sync with a random peer. Peers overwrite stale data with fresher information from their peers.

While the gossip protocol used is guaranteed to converge within a logarithmic number of rounds, if you require strict convergence SLAs a Gossip Sidecar may not be the right tool for your use-case.

How can I use it?

Docker images are availble in .tar format in releases. To deploy on Kubernetes, a starting config is available in k8s-deploy.yaml. You will probably want to edit the spec to include your own application container, and possibly change the containerPort to something other than port 80.

Once deployed, another process running on the same pod can access the container by sending HTTP requests to localhost:80. The following endpoints are available to interact with the key-value store.

How can I write to Gossipcar?

PUT http://localhost:80/map?k=<key>

REQUEST BODY:

[Octet stream of data to be associated with "key"]

RESPONSE HEADERS:

Content-Length: 0

RESPONSE BODY:

EMPTY

RESPONSE CODES:

How can I read from Gossipcar?

GET http://localhost:80/map?k=<key1>&k=<key2>...

RESPONSE HEADERS:

Content-Type: application/octect-stream
Content-Length: [number of bytes in body]

RESPONSE CONTENT:

<key1>=<value1>\n
<key2>=<value2>\n
...

RESPONSE CODES:

NOTES: