zookeeper-operator icon indicating copy to clipboard operation
zookeeper-operator copied to clipboard

Add the multiAddress.enabled cluster option present in zk >3.6.0

Open cstaff14 opened this issue 1 year ago • 0 comments

Change log description

  • Enable the multiaddreses.Enabled JVM flag in the zkserver.sh
  • parse inputted extra addresses and add them to the zoo config (2-3 concise points about the changes in this PR. When committing this PR, the committer is expected to copy the content of this section to the merge description box)

Purpose of the change

In zookeeper > 3.6.0 you can specify multiple addresses for a singular zookeeper server. here is the description of that cluster option. This update allows you to leverage that feature through the operator. This can also be useful if you want to expose individual zk servers through external addresses. (e.g., Fixes #666, Closes #1234)

What the code does

  • Add funcitionality to parse a list of zk server addresses in additionalConfig when creating the config map
  • in the zookeeper image, parse those additional addresses and properly use them in the zk config
    • The operator currently writes server addresses on write config and node registration. When one of these events happen we add an extra step that:
      • parses the new addServerAddresses.txt created by the config map for addresses listed for the current server ID
      • if there is a "|" it formats each address using the zkconfig function, otherwise it adds the singular address
      • it also removes the client port that is appended by the zkconfig function for all addresses except the final one in the list. This is to follow formatting for the multiAddress feature as the client port should only be present once per list of servers

(Detailed description of the code changes)

How to verify it

  1. add the -Dzookeeper.multiAddress.enabled=true flag to the value of the SERVER_JVMFLAGS env variable in your pod definition.
pod:
  ...
  env:
    - name: SERVER_JVMFLAGS
      value: "-Dzookeeper.multiAddress.enabled=true"
  1. Then add your additional addresses to the config definition of your ZookeeperCluster CRD in the format server.<id>: <address1>|<address2>|...
    config:
      ...
      additionalConfig {
        server.1: "zoo1-net1.net|zoo1-net2.net",
        server.2: "zoo2-net1.net",
        server.4: "zoo4-net1.net|zoo4-net2.net|zoo4-net3.net"
      }
    
    
  2. Validate correct address list is displayed through k8s portforwarding
    $ kubectl port-forward -n default zookeeper-0 2181:2181
    
     $ echo conf | nc localhost 2181
        ...
        membership: 
        server.1=app-zookeeper-0.app-zookeeper-headless.namespace.svc.cluster.local:2888:3888:participant|zoo1-net1.net:2888:3888|zoo1-net2.net:2888:3888:participant;0.0.0.0:2181
        server.2=app-zookeeper-0.app-zookeeper-headless.namespace.svc.cluster.local:2888:3888:participant|zoo2-net1.net:2888:3888:participant;0.0.0.0:2181
        server.3=app-zookeeper-0.app-zookeeper-headless.namespace.svc.cluster.local:2888:3888:participant;0.0.0.0:2181
        server.4=app-zookeeper-0.app-zookeeper-headless.namespace.svc.cluster.local:2888:3888:participant|zoo4-net1.net:2888:3888:participant|zoo4-net2.net:2888:3888:participant|zoo4-net3.net:2888:3888:participant;0.0.0.0:2181
        server.5=app-zookeeper-0.app-zookeeper-headless.namespace.svc.cluster.local:2888:3888:participant;0.0.0.0:2181
    
    

cstaff14 avatar Feb 23 '24 16:02 cstaff14