Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eliasdarruda/mnesia-with-k8s
https://github.com/eliasdarruda/mnesia-with-k8s
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/eliasdarruda/mnesia-with-k8s
- Owner: eliasdarruda
- Created: 2024-02-04T00:30:16.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-04T00:50:07.000Z (11 months ago)
- Last Synced: 2024-02-04T01:29:03.493Z (11 months ago)
- Language: Elixir
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mnesiac with Kubernetes
## Finally! Distributed Mnesia with Kubernetes!
This is a working example of using [Mnesiac](https://github.com/beardedeagle/mnesiac) clustered with [Libcluster](https://github.com/bitwalker/libcluster) using StatefulSet k8s configuration.
It implements a dummy writer that just keeps adding to a counter every 5 seconds.
Every pod is writing to the same counter, when you rollout to a new image, the state is kept correctly.
## Running
### You can find kubernetes manifests here [.k8s](.k8s)
You need to change in [config/prod.exs](config/prod.exs) the path that is going to be used by mnesia and your StatefulSet claim.
> config :test, abs_path: "/app/data/"
You also need to change [rel/env.sh.eex](rel/env.sh.eex) with the correct RELEASE_NODE attribute matching your k8s libcluster configuration, pv/pvc and statefulset.
> export RELEASE_NODE=mnesiac-example@$POD_NAME.mnesiac-cluster.default.svc.cluster.local
This example is using k3d, you need to setup a cluster and then do the following commands:
```BASH
k3d cluster create # if not yet createdkubectl apply -f .k8s/role.yaml
kubectl apply -f .k8s/role-binding.yaml
kubectl apply -f .k8s/pv.yaml
kubectl apply -f .k8s/pvc.yamldocker build -t mnesiac-example .
k3d image import mnesiac-examplekubectl apply -f .k8s/statefulset.yaml
```## Notes
- [lib/store.ex](lib/store.ex) - This is the most important part. The overrides needs to be configured exactly the way it is to work. It was very hard to figure that out but apparently this works well in rollouts.- [lib/application.ex](lib/application.ex) - Very important to set that abs_path hacky stuff.
- [lib/healthcheck/router.ex](lib/healthcheck/router.ex) - Bandit was used just to setup a basic healthcheck, its always recommended to work with a healthcheck when working with StatefulSets.