[PoC] Distributed Cache with Akka Cluster Sharding and Akka HTTP on Kubernetes
git clone https://github.com/sharma-rohit/distributed-cache-on-k8s-poc.git
-
Install minikube:
brew cask install minikube
-
Inatall kubectl:
brew install kubectl
-
Start minikube with --insecure-registry option:
minikube start --insecure-registry localhost:5000
-
Setup minikube Ingress controller:
minikube addons enable ingress
-
To make the local
docker
command use the minikube vm as docker host and all commands starting withdocker
affecting the minikube vm not the host computer run:eval $(minikube docker-env)
-
docker run -d -p 5000:5000 --restart=always --name registry -v /data/docker-registry:/var/lib/registry registry:2
-
To build and publish docker image to local registry of minikube run:
sbt docker:publish
-
Create kubernetes manifests:
kubectl create -f kubernetes/statefulset.yaml
kubectl apply -f kubernetes/service.yaml
kubectl apply -f kubernetes/headless_service.yaml
kubectl apply -f kubernetes/ingress.yaml
-
To redirect traffic from the domain "distributed-cache.com" stated in ingress.yaml to our minikube cluster run:
echo "$(minikube ip) distributed-cache.com" | sudo tee -a /etc/hosts
Check if it's working:
curl -v distributed-cache.com/cache-data/2055e73f-7db8-49ce-9eb6-3f9d80525284