jgroups-kubernetes BindException

3/22/2019

I used infinispan in the spring boot project, and I know that jgroups complete node communication and discovery in infinispan. I can already do multi-instance mutual discovery on the dockers. Now the problem is on Kubernetes.

The jgroups configuration file default-jgroups-kubernetes.xml I used was found in the official package of infinispan. I only modified tcp.port and the KUBE_PING tag:

<config xmlns="urn:org:jgroups"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups-4.0.xsd">

   <TCP bind_addr="${jgroups.tcp.address:match-interface:eth.*}"
        bind_port="${jgroups.tcp.port:30001}"
        enable_diagnostics="false"
        thread_naming_pattern="pl"
        send_buf_size="640k"
        sock_conn_timeout="300"
        bundler_type="no-bundler"
        logical_addr_cache_expiration="360000"

        thread_pool.min_threads="${jgroups.thread_pool.min_threads:0}"
        thread_pool.max_threads="${jgroups.thread_pool.max_threads:200}"
        thread_pool.keep_alive_time="60000"
   />
   <kubernetes.KUBE_PING
     port_range="3000"
     namespace="default"
     masterProtocol="https"
     masterHost="https://192.1.5.110:32305"
     masterPort="32305"
   />
   <MERGE3 min_interval="10000" 
           max_interval="30000" 
   />
   <FD_SOCK />
   <!-- Suspect node `timeout` to `timeout + timeout_check_interval` millis after the last heartbeat -->
   <FD_ALL timeout="10000"
           interval="2000"
           timeout_check_interval="1000"
   />
   <VERIFY_SUSPECT timeout="1000"/>
   <pbcast.NAKACK2 use_mcast_xmit="false"
                   xmit_interval="100"
                   xmit_table_num_rows="50"
                   xmit_table_msgs_per_row="1024"
                   xmit_table_max_compaction_time="30000"
                   resend_last_seqno="true"
   />
   <UNICAST3 xmit_interval="100"
             xmit_table_num_rows="50"
             xmit_table_msgs_per_row="1024"
             xmit_table_max_compaction_time="30000"
   />
   <pbcast.STABLE stability_delay="500"
                  desired_avg_gossip="5000"
                  max_bytes="1M"
   />
   <pbcast.GMS print_local_addr="false"
               join_timeout="${jgroups.join_timeout:5000}"
   />
   <MFC max_credits="2m" 
        min_threshold="0.40"
   />
   <FRAG3/>
</config>

By the way, I have introduced the dependencies of jgroups-kubernetes

I used the above configuration, and then the following exception:

...
Caused by: java.net.BindException: no port available in range [30001 .. 30051] (bind_addr=xxxxx%eth0)
  at org.jgroups.util.Util.createServerSocket(Util.java:3512)
  ...

Where xxxxx represents an IPv6 address

I don't know how to solve this exception. I tried to change the TCP port to 7800, and then the range is unchanged. The result is still the above exception, but the information becomes [7800..7850]

Looking forward to your help.Thanks!

-- TJwoods
jgroups
kubernetes

1 Answer

3/25/2019

Try to use either IPv4 or IPv6, but not a mix of both. IPv4 can be forced by setting system property java.net.preferIPv4Stack to true. A port_range of 3000 doesn't make any sense, use a smaller number such as 10, depending on how many containers you're running in the same pod (1 might work, too). In masterHost you're also setting the port, that's not needed and may actually fail. As a matter of fact, none of the 3 master* properties need to be set, as Kubernetes sets these properties itself.

-- Bela Ban
Source: StackOverflow