diff options
author | solsson <solsson@gmail.com> | 2017-01-02 11:57:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-02 11:57:57 +0100 |
commit | 467ac9d15f41ca7e3849f14e45b3a7c9fa26bab4 (patch) | |
tree | 9d70e06950db19819e368a786bd74d5decaeb84a /zookeeper/init/on-start.sh | |
parent | 932307616aa4ccd59df42209d92e83aef244f3d0 (diff) | |
parent | e631d5856532aecd2dfc0a7662d6d7310a482c40 (diff) | |
download | kubernetes-kafka-467ac9d15f41ca7e3849f14e45b3a7c9fa26bab4.tar.gz kubernetes-kafka-467ac9d15f41ca7e3849f14e45b3a7c9fa26bab4.tar.bz2 kubernetes-kafka-467ac9d15f41ca7e3849f14e45b3a7c9fa26bab4.zip |
Merge pull request #14 from Yolean/statefulset
Convert PetSet to StatefulSet for k8s 1.5+
Diffstat (limited to 'zookeeper/init/on-start.sh')
-rwxr-xr-x | zookeeper/init/on-start.sh | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/zookeeper/init/on-start.sh b/zookeeper/init/on-start.sh deleted file mode 100755 index 392b82a..0000000 --- a/zookeeper/init/on-start.sh +++ /dev/null @@ -1,73 +0,0 @@ -#! /bin/bash - -# Copyright 2016 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# This script configures zookeeper cluster member ship for version of zookeeper -# >= 3.5.0. It should not be used with the on-change.sh script in this example. -# As of April-2016 is 3.4.8 is the latest stable. - -# Both /opt and /tmp/zookeeper are assumed to be volumes shared with the parent. -CFG=/opt/zookeeper/conf/zoo.cfg.dynamic -CFG_BAK=/opt/zookeeper/conf/zoo.cfg.bak -MY_ID_FILE=/tmp/zookeeper/myid -HOSTNAME=$(hostname) - -while read -ra LINE; do - PEERS=("${PEERS[@]}" $LINE) -done - -# Don't add the first member as an observer -if [ ${#PEERS[@]} -eq 1 ]; then - # We need to write our index in this list of servers into MY_ID_FILE. - # Note that this may not always coincide with the hostname id. - echo 1 > "${MY_ID_FILE}" - echo "server.1=${PEERS[0]}:2888:3888;2181" > "${CFG}" - # TODO: zkServer-initialize is the safe way to handle changes to datadir - # because simply starting will create a new datadir, BUT if the user changed - # pod template they might end up with 2 datadirs and brief split brain. - exit -fi - -# Every subsequent member is added as an observer and promoted to a participant -echo "" > "${CFG_BAK}" -i=0 -for peer in "${PEERS[@]}"; do - let i=i+1 - if [[ "${peer}" == *"${HOSTNAME}"* ]]; then - MY_ID=$i - MY_NAME=${peer} - echo $i > "${MY_ID_FILE}" - echo "server.${i}=${peer}:2888:3888:observer;2181" >> "${CFG_BAK}" - else - echo "server.${i}=${peer}:2888:3888:participant;2181" >> "${CFG_BAK}" - fi -done - -# Once the dynamic config file is written it shouldn't be modified, so the final -# reconfigure needs to happen through the "reconfig" command. -cp ${CFG_BAK} ${CFG} - -# TODO: zkServer-initialize is the safe way to handle changes to datadir -# because simply starting will create a new datadir, BUT if the user changed -# pod template they might end up with 2 datadirs and brief split brain. -/opt/zookeeper/bin/zkServer.sh start - -# TODO: We shouldn't need to specify the address of the master as long as -# there's quorum. According to the docs the new server is just not allowed to -# vote, it's still allowed to propose config changes, and it knows the -# existing members of the ensemble from *its* config. This works as expected, -# but we should correlate with more satisfying empirical evidence. -/opt/zookeeper/bin/zkCli.sh reconfig -add "server.$MY_ID=$MY_NAME:2888:3888:participant;2181" -/opt/zookeeper/bin/zkServer.sh stop |