Artemis HA with Kubernetes: UnknowHostException from other hosts

4/9/2018

I have an Artemis/JMS service in Kubernetes that i want to deploy in a 2 node cluster.

Here is my connector config for Artemis (broker.xml):

<connectors>
    <connector name="jms-service-0">tcp://jms-service-0.jms-service.default.svc.cluster.local:61616</connector>
    <connector name="jms-service-1">tcp://jms-service-1.jms-service.default.svc.cluster.local:61616</connector>
</connectors>

But when deploying in kubernetes 1.8 with this StatefulSet:

apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: jms-service
  labels: 
     app: jms-service
spec:
 serviceName: jms-service
 replicas: 2
 selector:
    matchLabels:
        app: jms-service
 template:
    metadata:
      labels:
         app: jms-service
    spec:  
        containers:
        - name: jms-service
          image: kube-registry:5000/tk/jms-service:2.4
          ports:
            - containerPort: 8161
            - containerPort: 61616
            - containerPort: 5445
            - containerPort: 5672
            - containerPort: 1883
            - containerPort: 61613
          env:
            - name: ARTEMIS_USERNAME
              value: admin
            - name: ARTEMIS_PASSWORD
              value: admin

And this Service:

apiVersion: v1
kind: Service
metadata:
  name:  jms-service  
  annotations:
       service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:
  ports:
    - port: 8161
      nodePort: 30001
      name: webserver
    - port: 61616
      nodePort: 30002
      name: core
    - port: 5445
      nodePort: 30003
      name: hornetq
    - port: 5672
      nodePort: 30004
      name: amqp
    - port: 1883
      nodePort: 30005
      name: mqtt
    - port: 61613
      nodePort: 30006
      name: stomp
  selector:
    app: jms-service
  type:
    NodePort

Each pod doesn't see the other on start up.

For jms-service-0:

08:06:30,811 ERROR [org.apache.activemq.artemis.core.client] AMQ214016: Failed to create netty connection: java.net.UnknownHostException: jms-service-1.jms-service.default.svc.cluster.local
at java.net.InetAddress.getAllByName0(InetAddress.java:1280) [rt.ja

And for jms-service-1:

08:06:34,703 ERROR [org.apache.activemq.artemis.core.client] AMQ214016: Failed to create netty connection: java.net.UnknownHostException: jms-service-0.jms-service.default.svc.cluster.local

I think it's because until the pods are ready the DNS are not visible, but i'm not sure.

How can I solve this?

-- Fernando Guardiola
activemq
activemq-artemis
high-availability
kubernetes

1 Answer

7/26/2018

the service, in your case jms-service, definition is incorrect. the service that binds the backend pods ( from statefulsets ) should be defined as headless service

-- P Ekambaram
Source: StackOverflow