- This example shows how to run a sample proxy service which uses Hazelcast Go Client connected to the Hazelcast members in the same network and exposes itself to the outside through k8s ingress.
The guide assumes that Docker Engine is ready and running properly. You can run it on other container and virtual machine environments, but it is not tested.
- Open a new terminal session and type the following commands one by one in a row to observe the service.
git clone https://github.com/hazelcast/hazelcast-go-client.git
cd hazelcast-go-client/examples/k8s/service
minikube start --driver=docker
minikube docker-env
eval $(minikube -p minikube docker-env)
- Open another new terminal session.
minikube addons enable ingress
sudo minikube tunnel
- Go back to previous session and continue on with
docker build -t example/hz-go-service .
- Add
127.0.0.1 hz-go-service.info
at the bottom of the/etc/hosts
file. chmod +x start-deployment.sh
- Then,
./start-deployments.sh
- After that point, status of all k8s resources can be examined through:
kubectl get all
kubectl logs pod/hazelcast-sample-0
: checks whether Hazelcast members are up and running.- As a last step, lets ensure that the service is up and running by the help of ingress ip resolution:
curl hz-go-service.info
- Returns properties of the service and the Hazelcast Client as a json.
❯ curl hz-go-service.info/config { "ServiceConfig": { "ServiceName": "hazelcast-go-client-proxy-service", "Port": 8080, "Timeout": 5000000000 }, "HazelcastClientInfo": { "Name": "proxy-service-go-client", "Running": true, "MapSize": 3 } }%
- Returns the value of the entry that matches with
key1
.❯ curl 'hz-go-service.info/map?name=myDistributedMap&key=key1' {"Key":"key1","Value":"value1"}%
- Returns the value of the entry that matches with
key2
.❯ curl 'hz-go-service.info/map?name=myDistributedMap&key=key2' {"Key":"key2","Value":"value2"}%
- Changes the value of existing entry that has
key1
as a key of the given map through POST request.❯ curl -H "Content-Type: application/json" --data-binary '{"value": "myValue"}' -X POST 'hz-go-service.info/map?name=myDistributedMap&key=key1' Value: myValue has been put to map: myDistributedMap successfully.
- Returns the updated value of the entry that matches with
key1
.❯ curl 'hz-go-service.info/map?name=myDistributedMap&key=key1' {"Key":"key1","Value":"myValue"}%
./delete-deployments.sh
- Turn of running Minikube tunnel.
- Open a new terminal session.
export HZ_GO_SERVICE_WITHOUT_K8S=true
- Open another new terminal session.
hz
CLI tool is need. For detailed information, here.- Then,
hz start
: Starts a new Hazelcast cluster in local through CLI.
- Go back to previous session and check out
Operations
.