Skip to content

Latest commit

 

History

History

hazelcast-sidecar-js

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Hazelcast Sidecar Pattern (JS)


Build & Run

Skaffold

Execute Skaffold in dev mode

skaffold dev
Kubectl
  1. Build Docker image and Push
docker build -t bitxon/app-hz-sidecar-js:latest .
docker push bitxon/app-hz-sidecar-js:latest
  1. Deploy to Kubernetes
# Apply hazelcast RBAC
kubectl apply -f k8s/hazelcast-rbac.yaml
# Create hazelcast configmap
kubectl apply -f k8s/hazelcast-configmap.yaml
# Expose hazelcast(5701) for discovery
kubectl apply -f k8s/hazelcast-service.yaml
# Create application deployment
kubectl apply -f k8s/app-deployment.yaml
# Expose application(8080)
kubectl apply -f k8s/app-service.yaml
  1. Expose service port to local machine
kubectl port-forward service/application-service 8080:8080

Cleanup

kubectl delete -f k8s/app-service.yaml
kubectl delete -f k8s/app-deployment.yaml
kubectl delete -f k8s/hazelcast-service.yaml
kubectl delete -f k8s/hazelcast-configmap.yaml
kubectl delete -f k8s/hazelcast-rbac.yaml

Test your setup

# Put Value
curl --request PUT 'http://localhost:8080/cache/key1/valueA'
# Get Value
curl --request GET 'http://localhost:8080/cache/key1'
# Put Value to Locked cache (5 seconds long)
curl --request PUT 'http://localhost:8080/fenced-lock-cache/key1/valueB'
# Get Value from Locked cache (max wait 6 seconds)
curl --request GET 'http://localhost:8080/fenced-lock-cache/key1'
# Scale application
kubectl scale deployment application-deployment --replicas=5

Useful links