confluentinc / cp-docker-images

[DEPRECATED] Docker images for Confluent Platform.
Apache License 2.0
1.14k stars 703 forks source link

[cp-zookeeper] detect ZOOKEEPER_SERVER_ID in kubernetes #402

Open gAmUssA opened 6 years ago

gAmUssA commented 6 years ago

Currently ZOOKEEPER_SERVER_ID needs to be set otherwise container will fail to start. Because ZOOKEEPER_SERVER_ID used as a template to fulfill zookeeper's myid file. image 1 In Kubernetes environment, myid should be generated based on id of StatefulSet pod instance.

jesen-surjadi commented 6 years ago

have you tried using kubernetes downward api for specifying the ZOOKEEPER_SERVER_ID?

something like this would generate the unique ZOOKEEPER_SERVER_ID based on the pod name


      env:
        - name: ZOOKEEPER_SERVER_ID
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
ArnauPrat commented 6 years ago

I managed to make it work by specifying the docker container command at the kubernetes .yaml file as follows

        command:                                                                                                                                                                                                   
        - /bin/bash                                                                                                                                                                                                
        - -c                                                                                                                                                                                                       
        - export ZOOKEEPER_SERVER_ID=$((${HOSTNAME##*-}+1)) && /etc/confluent/docker/run