Closed TockaAyman-VG closed 5 years ago
@TockaAyman-VG Do you have a service defined?
You can check the Kubernetes Code Samples for more info [1]. I'll also add the information about the service to README.
Yes I have a service for hazelcast which I took from the example you mentioned, here are all my yaml files rbac.yaml , config.yaml and hazelcast.yaml are all exactly like the example you mentioned except for changing the version to 3.8.2 to be like the one used by vertx app service.yaml
apiVersion: v1
kind: Service
metadata:
name: appName
labels:
app: appName
spec:
type: NodePort
ports:
- port: 8080
protocol: TCP
selector:
app: appName
app deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: appName
spec:
replicas: 3
template:
metadata:
labels:
app: appName
spec:
containers:
- name: appName
image: appImageURL:appImageTag
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: /api/v1/health
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
and here is my ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: staging-ingress
spec:
rules:
- http:
paths:
- backend:
serviceName: appName
servicePort: 8080
path: "/api/v1/appName/*"
I am wondering if I should do some thing to direct my app to call the hazelcast service as I suspect that this line in logs is the problem
INFO: No cluster-host specified so using address 10.16.0.12
the used ip address in this log statement is the Pod's IP address
@TockaAyman-VG ok, the other thing you may be missing is exposing the Hazelcast port 5701
from your PODs. Could you try to add the following and try again?
- name: hazelcast
containerPort: 5701
Unfortunately after adding it no thing changed, the same behavior happened
You probably need also a service which exposes the port 5701
. Could you create one and try again?
ports:
- port: 8080
protocol: TCP
Do you mean I need to expose 5701 on the nodes level? Or I need to have a specific pod and service to listen on port 5701? [By the way kubernetes does not allow me to expose node port outside of 30000-32767 range] I think hazelcast service itself is listening on 5701 but it is mapped to another node port by kubernetes However I exposed port 5701 from the app service and the same behavior happened Here is how kubernetes services are configured now
> kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hazelcast-service LoadBalancer 10.19.251.152 130.211.196.234 5701:30931/TCP 1h
kubernetes ClusterIP 10.19.240.1 <none> 443/TCP 1h
appservice NodePort 10.19.245.224 <none> 8080:32295/TCP,5701:30368/TCP 50s
and this is the updated deployment.xml file
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: appName
spec:
replicas: 3
template:
metadata:
labels:
app: appName
spec:
containers:
- name: appName
image: AppImageURL:AppImageTag
ports:
- name: app
containerPort: 8080
- name: hazelcast
containerPort: 5701
livenessProbe:
httpGet:
path: /api/v1/health
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
and here is the updated app service.xml
apiVersion: v1
kind: Service
metadata:
name: appName
labels:
app: appName
spec:
type: NodePort
ports:
- name: app
port: 8080
protocol: TCP
- name: hazelcast
port: 5701
protocol: TCP
selector:
app: appName
hazelcast-service
should actually be enough. Could you paste here the YAML for hazecast-service
?
Also, I don't see the matchSelector
in your Deployment config. Could you try to add it?
selector:
matchLabels:
app: appName
@TockaAyman-VG I've created also a Code Sample with the minimum configuration to run embedded Hazelcast on Kubernetes. You can have a look: https://github.com/leszko/hazelcast-code-samples/tree/kubernetes-embedded/hazelcast-integration/kubernetes/samples/embedded
Hope it'll help.
@leszko Finally, it worked.
I tried your code in a new cluster, it worked. Then I just changed from your image to mine with changing nothing else, it does not work. So I knew that the problem was inside my docker image.
There was two differences between yours and mine:
I noticed that vertx event bus client takes configuration for the internal hazelcast client through a file called cluster.xml as stated on their official documentation https://vertx.io/docs/vertx-hazelcast/java/ While hazelcast client takes configuration through hazelcast.xml file. So I renamed the file and every thing works just fine.
It is really confusing, but I am glade it worked.
Thank you very much, you saved my day.
Great to hear that @TockaAyman-VG . If you see any improvement that could be done to the configuration, could you please raise a related GH issue in the Hazelcast or Vertx GH repo? That could be helpful.
I'm closing the issue for now. Please feel free to reopen if needed.
I noticed that all samples are using same pod with replicas, which actually works and if i scale the pod i can see the other replicas joining the cluster, but my issue is that i have a two different pods and each is having its own cluster. @leszko what would you change in that example for 2 deployments to join the same cluster?!
@vegegoku You can create a service (can be just ClusterIP
) and then point both PODs in the service selector. Then, use the service name in the Hazelcast Kubernetes configuration.
Hello all, I am trying to get hazelcast up and running on kubernetes cluster [I am using vertx framework in the app] , I am almost done except that each pod is forming it is own cluster. Can any one tell me what is wrong in my configuration, Thanks in advance
I added this in my gradle dependencies
compile group: 'io.vertx', name: 'vertx-hazelcast', version: '3.5.4'
which internally added com.hazelcast:hazelcast:3.8.2This is my cluster.xml I added it in the resource folder in my app `<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.8.xsd" xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
`
I added rbac.yaml
then deployed my deployment and service.
I also updated my docker file run command to use
java -jar jarName -cluster
and here is the starting logs