{"id":13741016,"url":"https://github.com/mhausenblas/mehdb","last_synced_at":"2026-03-13T22:35:18.233Z","repository":{"id":54511265,"uuid":"137855794","full_name":"mhausenblas/mehdb","owner":"mhausenblas","description":"Educational Kubernetes-native NoSQL datastore using StatefulSet and persistent volumes","archived":false,"fork":false,"pushed_at":"2021-02-14T14:28:14.000Z","size":17,"stargazers_count":22,"open_issues_count":1,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T20:14:31.858Z","etag":null,"topics":["kubernetes","persistent-volume","stateful","statefulsets"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mhausenblas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-19T07:29:14.000Z","updated_at":"2025-02-22T02:34:15.000Z","dependencies_parsed_at":"2022-08-13T18:10:55.698Z","dependency_job_id":null,"html_url":"https://github.com/mhausenblas/mehdb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mhausenblas/mehdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhausenblas%2Fmehdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhausenblas%2Fmehdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhausenblas%2Fmehdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhausenblas%2Fmehdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mhausenblas","download_url":"https://codeload.github.com/mhausenblas/mehdb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhausenblas%2Fmehdb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30478189,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T20:45:58.186Z","status":"ssl_error","status_checked_at":"2026-03-13T20:45:20.133Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kubernetes","persistent-volume","stateful","statefulsets"],"created_at":"2024-08-03T04:00:54.536Z","updated_at":"2026-03-13T22:35:18.195Z","avatar_url":"https://github.com/mhausenblas.png","language":"Go","funding_links":[],"categories":["Databases"],"sub_categories":[],"readme":"# mehdb\n\nThis is `mehdb`, an educational Kubernetes-native NoSQL data store. It is not meant for production usage but purely to learn and experiment with [StatefulSets](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/).\n\n## Usage\n\nDeploy it:\n\n```bash\n$ kubectl create ns mehdb\n$ kubectl -n=mehdb apply -f app.yaml\n```\n\nAccess it from within the cluster:\n\n```\n$ kubectl -n=mehdb run -i -t --rm jumpod --restart=Never --image=quay.io/mhausenblas/jump:0.2 -- sh\n$ echo \"test data\" \u003e /tmp/test\n$ curl -L -XPUT -T /tmp/test mehdb:9876/set/test\n$ curl mehdb:9876/get/test\n$ curl mehdb-1.mehdb:9876/get/test\n```\n\nScale to 3 shards (1 leader, 2 followers):\n\n```bash\n$ kubectl -n=mehdb scale sts mehdb --replicas=4\n```\n\nClean up:\n\n```bash\n$ kubectl -n=mehdb delete sts/mehdb\n$ kubectl -n=mehdb delete pvc/data-mehdb-0\n$ kubectl -n=mehdb delete pvc/data-mehdb-1\n$ kubectl -n=mehdb delete svc/mehdb\n```\n\nNote: I tested it in OpenShift Online with Kubernetes in version 1.9 and the setup assumes that a storage class `ebs` exists.\n\n## API\n\nOnce deployed you can use `mehdb` to store and retrieve data. Keep the following in mind:\n\n- The keys are restricted, that is, they must match `[a-z]+`. For example, `abc` is a valid key, `123` or `_mykey42` is not.\n- The leader shard accepts both reads and writes, a follower shard will redirect to the leader shard if you attempt a write operation.\n\nThe following public endpoints are available:\n\n`/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.\n\n`/set/$KEY` … a HTTP `PUT` at this endpoint stores the payload provided under the key `$KEY`.\n\n`/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.\n\n## Local development\n\nRun a leader shard like so:\n\n```bash\n$ MEHDB_HOST=mehdb-0 MEHDB_PORT=9999 go run main.go\n```\n\nRun a follower shard like so:\n\n```bash\n$ MEHDB_LOCAL=yes MEHDB_DATADIR=./follower-data go run main.go\n```\n\nNow you can for example write to and/or read from the leader:\n\n```bash\n$ http PUT localhost:9999/set/abc \u003c test/somedata\n$ http localhost:9999/get/abc\n```\n\nAlso, you can read from the follower:\n\n```bash\n$ http localhost:9876/get/abc\n```\n\nIf you try to write to the follower, you'll be redirected:\n\n```bash\n$ http PUT localhost:9876/set/abc \u003c test/somedata\nHTTP/1.1 307 Temporary Redirect\nContent-Length: 0\nDate: Tue, 19 Jun 2018 12:28:57 GMT\nLocation: http://localhost:9999/set/abc\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhausenblas%2Fmehdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmhausenblas%2Fmehdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhausenblas%2Fmehdb/lists"}