Cp-docker-images: [cp-zookeeper] detect ZOOKEEPER_SERVER_ID in kubernetes

Created on 8 Jan 2018  路  2Comments  路  Source: confluentinc/cp-docker-images

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.

enhancement

Most helpful comment

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  

All 2 comments

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

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  
Was this page helpful?
0 / 5 - 0 ratings