You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for custom init scripts which can be mounted to /docker-entrypoint.d/ directory.
This will allow more easier, flexible and elegant customization. For example, to deploy a ZooKeeper cluster in Kubernetes, user can mount a custom init script to calculate ZOO_MY_ID for each instance.
*.envsh: environment script, it will be executed by source command, and can be used to export environment variables which will be visible to docker-entrypoint.sh
*.sh: normal script, normally it should have a shebang to declare how to execute it
Note:
Files that not ends with .envsh or .sh will be ignored
Each init script must have execute permission, otherwise it will be ignored to reduce security risks
If the container is started by root user (the default case), the init scripts will be executed after switching to zookeeper user
Kubernetes example to mount a init script from ConfigMap:
apiVersion: v1kind: ConfigMapmetadata:
name: zookeeper-configdata:
set-my-id.envsh: | #!/bin/bash HOST=`hostname -s` DOMAIN=`hostname -d` if [[ $HOST =~ (.*)-([0-9]+)$ ]]; then NAME=${BASH_REMATCH[1]} ORD=${BASH_REMATCH[2]} else echo "Failed to parse name and ordinal of Pod" exit 1 fi servers= for (( i=1; i<=$ZOO_SERVERS_COUNT; i++ )); do [[ -n "$servers" ]] && servers+=" " servers+="server.$i=$NAME-$((i-1)).$DOMAIN:2888:3888;2181" done export ZOO_MY_ID="$((ORD+1))" export ZOO_SERVERS="$servers" echo "Setting ZOO_MY_ID=$ZOO_MY_ID" echo "Setting ZOO_SERVERS=$ZOO_SERVERS"
---
apiVersion: apps/v1kind: StatefulSetspec:
template:
spec:
volumes:
- name: zookeeper-configconfigMap:
name: zookeeper-configitems:
- key: set-my-id.envshpath: set-my-id.envshmode: 0555containers:
- name: kubernetes-zookeeperimage: zookeeper:3.9.2volumeMounts:
- name: zookeeper-configmountPath: /docker-entrypoint.d/set-my-id.envshsubPath: set-my-id.envsh
As mentioned in #145 (comment) it's already possible to mount a custom zookeeper-env.sh and therefore adjust Zookeeper configuration via a shell script. So I don't think it's worth it to increase the complexity of the current image entrypoint.
Maybe extend the "Advanced configuration" section of the docs with an example of using zookeeper-env.sh to customize the config?
As mentioned in #145 (comment) it's already possible to mount a custom zookeeper-env.sh and therefore adjust Zookeeper configuration via a shell script. So I don't think it's worth it to increase the complexity of the current image entrypoint.
Maybe extend the "Advanced configuration" section of the docs with an example of using zookeeper-env.sh to customize the config?
Yes, zookeeper-env.sh works, but personally I think it's not elegant, and I double whether it's the intended use case of ZooKeeper maintainer.
Okay if you insist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See #145
Add support for custom init scripts which can be mounted to
/docker-entrypoint.d/directory.This will allow more easier, flexible and elegant customization. For example, to deploy a ZooKeeper cluster in Kubernetes, user can mount a custom init script to calculate
ZOO_MY_IDfor each instance.The idea and code is borrowed from official Nginx image.
There are two kinds of init scripts:
*.envsh: environment script, it will be executed bysourcecommand, and can be used to export environment variables which will be visible todocker-entrypoint.sh*.sh: normal script, normally it should have a shebang to declare how to execute itNote:
.envshor.shwill be ignoredzookeeperuserKubernetes example to mount a init script from ConfigMap: