All Projects → mhausenblas → mehdb

mhausenblas / mehdb

Licence: Apache-2.0 license
Educational Kubernetes-native NoSQL datastore using StatefulSet and persistent volumes

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to mehdb

ripple
Simple shared surface streaming application
Stars: ✭ 17 (-22.73%)
Mutual labels:  stateful
moosefs-csi
Container Storage Interface (CSI) for MooseFS
Stars: ✭ 44 (+100%)
Mutual labels:  persistent-volume
tutorial
Tutorials to help you build your first Swim app
Stars: ✭ 27 (+22.73%)
Mutual labels:  stateful
zookeeper-k8s-openshift
Zookeeper docker container, ready for deployments on kubernetes and openshift
Stars: ✭ 22 (+0%)
Mutual labels:  statefulsets
StatefulLiveData
StatefulLiveData is a lean, yet powerful tool that harnesses the capabilities of LiveData and enhances them, enabling the observer to distinguish between different states the data can be in, such as Success, Loading and Error.
Stars: ✭ 18 (-18.18%)
Mutual labels:  stateful
kubernetes-kafka
Kafka integration for Kubernetes
Stars: ✭ 80 (+263.64%)
Mutual labels:  statefulsets
compost
Manage lifecycle of stateful components
Stars: ✭ 15 (-31.82%)
Mutual labels:  stateful
angular-webpack-material-lazyload-typescript-starter-template
Angular starter template using typescript, angular-material, ui-router, oclazyload with webpack support.
Stars: ✭ 55 (+150%)
Mutual labels:  stateful
Reloader
Reloader is maintained by Stakater. Like it? Please let us know at [email protected]
Stars: ✭ 2,930 (+13218.18%)
Mutual labels:  statefulsets
atlassian-kubernetes
All things Atlassian and Kubernetes
Stars: ✭ 30 (+36.36%)
Mutual labels:  statefulsets
mishka-cms
MishkaCms an open source and real time API base CMS Powered by Elixir and Phoenix
Stars: ✭ 37 (+68.18%)
Mutual labels:  stateful
SEEP
Cluster computing using Stateful Dataflow Graphs
Stars: ✭ 25 (+13.64%)
Mutual labels:  stateful
transit
Massively real-time city transit streaming application
Stars: ✭ 20 (-9.09%)
Mutual labels:  stateful
PageStatusTransformer
A low invasive state management on Android
Stars: ✭ 12 (-45.45%)
Mutual labels:  stateful
traffic
Massively real-time traffic streaming application
Stars: ✭ 25 (+13.64%)
Mutual labels:  stateful

mehdb

This is mehdb, an educational Kubernetes-native NoSQL data store. It is not meant for production usage but purely to learn and experiment with StatefulSets.

Usage

Deploy it:

$ kubectl create ns mehdb
$ kubectl -n=mehdb apply -f app.yaml

Access it from within the cluster:

$ kubectl -n=mehdb run -i -t --rm jumpod --restart=Never --image=quay.io/mhausenblas/jump:0.2 -- sh
$ echo "test data" > /tmp/test
$ curl -L -XPUT -T /tmp/test mehdb:9876/set/test
$ curl mehdb:9876/get/test
$ curl mehdb-1.mehdb:9876/get/test

Scale to 3 shards (1 leader, 2 followers):

$ kubectl -n=mehdb scale sts mehdb --replicas=4

Clean up:

$ kubectl -n=mehdb delete sts/mehdb
$ kubectl -n=mehdb delete pvc/data-mehdb-0
$ kubectl -n=mehdb delete pvc/data-mehdb-1
$ kubectl -n=mehdb delete svc/mehdb

Note: I tested it in OpenShift Online with Kubernetes in version 1.9 and the setup assumes that a storage class ebs exists.

API

Once deployed you can use mehdb to store and retrieve data. Keep the following in mind:

  • The keys are restricted, that is, they must match [a-z]+. For example, abc is a valid key, 123 or _mykey42 is not.
  • The leader shard accepts both reads and writes, a follower shard will redirect to the leader shard if you attempt a write operation.

The following public endpoints are available:

/get/$KEY … a HTTP GET at this endpoint retrieves the payload available under the key $KEY or a 404 if the key does not exist.

/set/$KEY … a HTTP PUT at this endpoint stores the payload provided under the key $KEY.

/status … by default returns a 200 and the role (leader or follower), which can be used for a liveness probe, with ?level=full it returns a 200 and the number of keys it can serve, which can be used for a readiness probe.

Local development

Run a leader shard like so:

$ MEHDB_HOST=mehdb-0 MEHDB_PORT=9999 go run main.go

Run a follower shard like so:

$ MEHDB_LOCAL=yes MEHDB_DATADIR=./follower-data go run main.go

Now you can for example write to and/or read from the leader:

$ http PUT localhost:9999/set/abc < test/somedata
$ http localhost:9999/get/abc

Also, you can read from the follower:

$ http localhost:9876/get/abc

If you try to write to the follower, you'll be redirected:

$ http PUT localhost:9876/set/abc < test/somedata
HTTP/1.1 307 Temporary Redirect
Content-Length: 0
Date: Tue, 19 Jun 2018 12:28:57 GMT
Location: http://localhost:9999/set/abc
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].