aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStaffan Olsson <staffan@repos.se>2016-10-17 13:22:16 +0200
committerStaffan Olsson <staffan@repos.se>2016-10-25 12:15:02 +0200
commit5178026340f3ed2fc84238345628515e5c2ee621 (patch)
tree8db5fc0dca996f328d1c214f1b708a03d00448cc
parenta55b9c88cf5e722a417ef6da20c72d5786a7c136 (diff)
downloadkubernetes-kafka-5178026340f3ed2fc84238345628515e5c2ee621.tar.gz
kubernetes-kafka-5178026340f3ed2fc84238345628515e5c2ee621.tar.bz2
kubernetes-kafka-5178026340f3ed2fc84238345628515e5c2ee621.zip
Single pod zookeeper, now that PetSet is de-supported in GKE
-rw-r--r--zookeeper/30service.yml (renamed from zookeeper/service.yml)2
-rw-r--r--zookeeper/51zoo.yml46
-rwxr-xr-xzookeeper/bootstrap/pv.sh2
-rw-r--r--zookeeper/init/Dockerfile29
-rw-r--r--zookeeper/init/Makefile27
-rwxr-xr-xzookeeper/init/install.sh76
-rwxr-xr-xzookeeper/init/on-change.sh49
-rwxr-xr-xzookeeper/init/on-start.sh73
-rw-r--r--zookeeper/zookeeper.yaml128
9 files changed, 48 insertions, 384 deletions
diff --git a/zookeeper/service.yml b/zookeeper/30service.yml
index e11e791..f33f393 100644
--- a/zookeeper/service.yml
+++ b/zookeeper/30service.yml
@@ -9,4 +9,4 @@ spec:
- port: 2181
name: client
selector:
- app: zk
+ app: zookeeper
diff --git a/zookeeper/51zoo.yml b/zookeeper/51zoo.yml
new file mode 100644
index 0000000..291fd6c
--- /dev/null
+++ b/zookeeper/51zoo.yml
@@ -0,0 +1,46 @@
+apiVersion: extensions/v1beta1
+kind: ReplicaSet
+metadata:
+ name: zoo-1
+ namespace: kafka
+spec:
+ replicas: 1
+ template:
+ metadata:
+ labels:
+ app: zookeeper
+ spec:
+ containers:
+ - name: zookeeper
+ image: zookeeper
+ env:
+ - name: ZOO_MY_ID
+ value: "1"
+ - name: ZOO_SERVERS
+ value: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
+ ports:
+ - containerPort: 2181
+ name: client
+ - containerPort: 2888
+ name: peer
+ - containerPort: 3888
+ name: leader-election
+ readinessProbe:
+ exec:
+ command:
+ - sh
+ - -c
+ - "/opt/zookeeper/bin/zkCli.sh ls /"
+ initialDelaySeconds: 15
+ timeoutSeconds: 5
+ volumeMounts:
+ - name: datadir
+ mountPath: /tmp/zookeeper
+ - name: opt
+ mountPath: /opt/
+ volumes:
+ - name: opt
+ emptyDir: {}
+ - name: datadir
+ persistentVolumeClaim:
+ claimName: datadir-zoo-0
diff --git a/zookeeper/bootstrap/pv.sh b/zookeeper/bootstrap/pv.sh
index 7bbe121..ade25c5 100755
--- a/zookeeper/bootstrap/pv.sh
+++ b/zookeeper/bootstrap/pv.sh
@@ -8,4 +8,4 @@ echo "Please enter a path where to store data during local testing: ($path)"
read newpath
[ -n "$newpath" ] && path=$newpath
-cat zookeeper/bootstrap/pv-template.yml | sed "s|/tmp/k8s-data|$path|" | kubectl create -f -
+cat $dir/bootstrap/pv-template.yml | sed "s|/tmp/k8s-data|$path|" | kubectl create -f -
diff --git a/zookeeper/init/Dockerfile b/zookeeper/init/Dockerfile
deleted file mode 100644
index d3e8aae..0000000
--- a/zookeeper/init/Dockerfile
+++ /dev/null
@@ -1,29 +0,0 @@
-# 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.
-
-# TODO: get rid of bash dependency and switch to plain busybox.
-# The tar in busybox also doesn't seem to understand compression.
-FROM debian:jessie
-MAINTAINER Prashanth.B <beeps@google.com>
-
-RUN apt-get update && apt-get install -y wget netcat
-
-ADD on-start.sh /
-ADD on-change.sh /
-# See contrib/pets/peer-finder for details
-RUN wget -qO /peer-finder https://storage.googleapis.com/kubernetes-release/pets/peer-finder
-
-ADD install.sh /
-RUN chmod -c 755 /install.sh /on-start.sh /on-change.sh /peer-finder
-Entrypoint ["/install.sh"]
diff --git a/zookeeper/init/Makefile b/zookeeper/init/Makefile
deleted file mode 100644
index bfb6978..0000000
--- a/zookeeper/init/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-# 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.
-
-all: push
-
-TAG = 0.1
-PREFIX = gcr.io/google_containers/zookeeper-install
-
-container:
- docker build -t $(PREFIX):$(TAG) .
-
-push: container
- gcloud docker push $(PREFIX):$(TAG)
-
-clean:
- docker rmi $(PREFIX):$(TAG)
diff --git a/zookeeper/init/install.sh b/zookeeper/init/install.sh
deleted file mode 100755
index 6ed7269..0000000
--- a/zookeeper/init/install.sh
+++ /dev/null
@@ -1,76 +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 volume is assumed to exist and is shared with parent of the init
-# container. It contains the zookeeper installation.
-INSTALL_VOLUME="/opt"
-
-# This volume is assumed to exist and is shared with the peer-finder
-# init container. It contains on-start/change configuration scripts.
-WORKDIR_VOLUME="/work-dir"
-
-# As of April-2016 is 3.4.8 is the latest stable, but versions 3.5.0 onward
-# allow dynamic reconfiguration.
-VERSION="3.5.0-alpha"
-
-for i in "$@"
-do
-case $i in
- -v=*|--version=*)
- VERSION="${i#*=}"
- shift
- ;;
- -i=*|--install-into=*)
- INSTALL_VOLUME="${i#*=}"
- shift
- ;;
- -w=*|--work-dir=*)
- WORKDIR_VOLUME="${i#*=}"
- shift
- ;;
- *)
- # unknown option
- ;;
-esac
-done
-
-echo installing config scripts into "${WORKDIR_VOLUME}"
-mkdir -p "${WORKDIR_VOLUME}"
-cp /on-start.sh "${WORKDIR_VOLUME}"/
-cp /on-change.sh "${WORKDIR_VOLUME}"/
-cp /peer-finder "${WORKDIR_VOLUME}"/
-
-echo installing zookeeper-"${VERSION}" into "${INSTALL_VOLUME}"
-mkdir -p "${INSTALL_VOLUME}"
-wget -q -O - http://apache.mirrors.pair.com/zookeeper/zookeeper-"${VERSION}"/zookeeper-"${VERSION}".tar.gz | tar -xzf - -C "${INSTALL_VOLUME}"
-mv "${INSTALL_VOLUME}"/zookeeper-"${VERSION}" "${INSTALL_VOLUME}"/zookeeper
-cp "${INSTALL_VOLUME}"/zookeeper/conf/zoo_sample.cfg "${INSTALL_VOLUME}"/zookeeper/conf/zoo.cfg
-
-# TODO: Should dynamic config be tied to the version?
-IFS="." read -ra RELEASE <<< "${VERSION}"
-if [ $(expr "${RELEASE[1]}") -gt 4 ]; then
- echo zookeeper-"${VERSION}" supports dynamic reconfiguration, enabling it
- echo "standaloneEnabled=false" >> "${INSTALL_VOLUME}"/zookeeper/conf/zoo.cfg
- echo "dynamicConfigFile="${INSTALL_VOLUME}"/zookeeper/conf/zoo.cfg.dynamic" >> "${INSTALL_VOLUME}"/zookeeper/conf/zoo.cfg
-fi
-
-# TODO: This is a hack, netcat is convenient to have in the zookeeper container
-# I want to avoid using a custom zookeeper image just for this. So copy it.
-NC=$(which nc)
-if [ "${NC}" != "" ]; then
- echo copying nc into "${INSTALL_VOLUME}"
- cp "${NC}" "${INSTALL_VOLUME}"
-fi
diff --git a/zookeeper/init/on-change.sh b/zookeeper/init/on-change.sh
deleted file mode 100755
index bb9a504..0000000
--- a/zookeeper/init/on-change.sh
+++ /dev/null
@@ -1,49 +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-start.sh script in this example.
-# As of April-2016 is 3.4.8 is the latest stable.
-
-CFG=/opt/zookeeper/conf/zoo.cfg
-CFG_BAK=/opt/zookeeper/conf/zoo.cfg.bak
-MY_ID=/tmp/zookeeper/myid
-
-# write myid
-IFS='-' read -ra ADDR <<< "$(hostname)"
-echo $(expr "1" + "${ADDR[1]}") > "${MY_ID}"
-
-# TODO: This is a dumb way to reconfigure zookeeper because it allows dynamic
-# reconfig, but it's simple.
-i=0
-echo "
-tickTime=2000
-initLimit=10
-syncLimit=5
-dataDir=/tmp/zookeeper
-clientPort=2181
-" > "${CFG_BAK}"
-
-while read -ra LINE; do
- let i=i+1
- echo "server.${i}=${LINE}:2888:3888" >> "${CFG_BAK}"
-done
-cp ${CFG_BAK} ${CFG}
-
-# TODO: Typically one needs to first add a new member as an "observer" then
-# promote it to "participant", but that requirement is relaxed if we never
-# start > 1 at a time.
-/opt/zookeeper/bin/zkServer.sh restart
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
diff --git a/zookeeper/zookeeper.yaml b/zookeeper/zookeeper.yaml
deleted file mode 100644
index ee2b237..0000000
--- a/zookeeper/zookeeper.yaml
+++ /dev/null
@@ -1,128 +0,0 @@
-# A headless service to create DNS records
-apiVersion: v1
-kind: Service
-metadata:
- annotations:
- service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
- name: zk
- namespace: kafka
- labels:
- app: zk
-spec:
- ports:
- - port: 2888
- name: peer
- - port: 3888
- name: leader-election
- # *.zk.kafka.svc.cluster.local
- clusterIP: None
- selector:
- app: zk
----
-apiVersion: apps/v1alpha1
-kind: PetSet
-metadata:
- name: zoo
- namespace: kafka
-spec:
- serviceName: "zk"
- replicas: 3
- template:
- metadata:
- labels:
- app: zk
- annotations:
- pod.alpha.kubernetes.io/initialized: "true"
- pod.alpha.kubernetes.io/init-containers: '[
- {
- "name": "install",
- "image": "gcr.io/google_containers/zookeeper-install:0.1",
- "imagePullPolicy": "Always",
- "args": ["--version=3.5.2-alpha", "--install-into=/opt", "--work-dir=/work-dir"],
- "volumeMounts": [
- {
- "name": "opt",
- "mountPath": "/opt/"
- },
- {
- "name": "workdir",
- "mountPath": "/work-dir"
- }
- ]
- },
- {
- "name": "bootstrap",
- "image": "java:openjdk-8-jre",
- "command": ["/work-dir/peer-finder"],
- "args": ["-on-start=\"/work-dir/on-start.sh\"", "-service=zk"],
- "env": [
- {
- "name": "POD_NAMESPACE",
- "valueFrom": {
- "fieldRef": {
- "apiVersion": "v1",
- "fieldPath": "metadata.namespace"
- }
- }
- }
- ],
- "volumeMounts": [
- {
- "name": "opt",
- "mountPath": "/opt/"
- },
- {
- "name": "workdir",
- "mountPath": "/work-dir"
- },
- {
- "name": "datadir",
- "mountPath": "/tmp/zookeeper"
- }
- ]
- }
- ]'
- spec:
- containers:
- - name: zk
- image: java:openjdk-8-jre
- ports:
- - containerPort: 2181
- name: client
- - containerPort: 2888
- name: peer
- - containerPort: 3888
- name: leader-election
- command:
- - /opt/zookeeper/bin/zkServer.sh
- args:
- - start-foreground
- readinessProbe:
- exec:
- command:
- - sh
- - -c
- - "/opt/zookeeper/bin/zkCli.sh ls /"
- initialDelaySeconds: 15
- timeoutSeconds: 5
- volumeMounts:
- - name: datadir
- mountPath: /tmp/zookeeper
- - name: opt
- mountPath: /opt/
- volumes:
- - name: opt
- emptyDir: {}
- - name: workdir
- emptyDir: {}
- volumeClaimTemplates:
- - metadata:
- name: datadir
- namespace: kafka
- annotations:
- volume.alpha.kubernetes.io/storage-class: anything
- spec:
- accessModes: [ "ReadWriteOnce" ]
- resources:
- requests:
- storage: 20Gi