hashber

command module
v0.0.0-...-d19350c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

hashber

My simple implementation of a distributed system with consistent hashing and a gossip protocol.

Getting started

Start your minikube cluster and share docker context

minikube start
eval $(minikube -p minikube docker-env)

Build the docker image

make docker

Create the docker deployment

kubectl create deploy hashber --image=hashber:latest --replicas=1 --port=8090 --port=7946

# patch the deployment to not pull images and use minikube local images
kubectl patch deployment hashber --patch '{"spec": {"template": {"spec": {"containers": [{"name": "hashber","imagePullPolicy": "Never"}]}}}}'

# patch again to allow pod to know their own IP adresse and avoid infinte loop
kubectl patch deployment hashber --patch '{"spec": {"template": {"spec": {"containers": [{"name": "hashber","env": [{"name": "MY_POD_IP", "valueFrom": {"fieldRef": {"fieldPath": "status.podIP"}}}]}]}}}}'

Expose memberlist via a service

kubectl expose deploy/hashber --name=hashber-memberlist --port=7946

Expose hashber http API via a NodePort service

kubectl expose deploy/hashber --name=hashber --port=8090 --type=NodePort

Then look at the logs and change replicas number in another terminal

kubectl scale --replicas=3 deploy/hashber

Contact the hello API, you need to find your minikube master ip

# get nodeport port
kubectl get svc

# call aPI
curl http://192.168.49.2:31290/hello

# launch multiple calls
for i in {1..1000}; do sleep 1;curl http://192.168.49.2:31290/hello; done

Look at the logs to see who receive the request and who respond to it.

How to re deploy a new version

make docker
kubectl patch deployment $1 -p "{\"spec\": {\"template\": {\"metadata\": { \"labels\": {  \"redeploy\": \"$(date +%s)\"}}}}}"

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址