Skip to content

Commit

Permalink
Merge pull request #39 from scholzj/zookeeper-healthcheck
Browse files Browse the repository at this point in the history
Add Zookeeper readiness and liveness check #3
  • Loading branch information
tombentley authored Oct 12, 2017
2 parents e2fd6bc + c62ad44 commit 6f37b67
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2 deletions.
12 changes: 12 additions & 0 deletions kafka-inmemory/resources/openshift-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ objects:
volumeMounts:
- mountPath: /var/lib/zookeeper
name: zookeeper-storage
livenessProbe:
exec:
command:
- "/opt/zookeeper/zookeeper_healthcheck.sh"
initialDelaySeconds: 15
timeoutSeconds: 5
readinessProbe:
exec:
command:
- "/opt/zookeeper/zookeeper_healthcheck.sh"
initialDelaySeconds: 15
timeoutSeconds: 5
dnsPolicy: ClusterFirst
restartPolicy: Always
volumes:
Expand Down
12 changes: 12 additions & 0 deletions kafka-inmemory/resources/zookeeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ spec:
volumeMounts:
- name: zookeeper-storage
mountPath: /var/lib/zookeeper
livenessProbe:
exec:
command:
- "/opt/zookeeper/zookeeper_healthcheck.sh"
initialDelaySeconds: 15
timeoutSeconds: 5
readinessProbe:
exec:
command:
- "/opt/zookeeper/zookeeper_healthcheck.sh"
initialDelaySeconds: 15
timeoutSeconds: 5
volumes:
- name: zookeeper-storage
emptyDir: {}
12 changes: 12 additions & 0 deletions kafka-statefulsets/resources/openshift-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ objects:
volumeMounts:
- mountPath: /var/lib/zookeeper
name: zookeeper-storage
livenessProbe:
exec:
command:
- "/opt/zookeeper/zookeeper_healthcheck.sh"
initialDelaySeconds: 15
timeoutSeconds: 5
readinessProbe:
exec:
command:
- "/opt/zookeeper/zookeeper_healthcheck.sh"
initialDelaySeconds: 15
timeoutSeconds: 5
dnsPolicy: ClusterFirst
restartPolicy: Always
volumeClaimTemplates:
Expand Down
12 changes: 12 additions & 0 deletions kafka-statefulsets/resources/zookeeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ spec:
volumeMounts:
- name: zookeeper-storage
mountPath: /var/lib/zookeeper
livenessProbe:
exec:
command:
- "/opt/zookeeper/zookeeper_healthcheck.sh"
initialDelaySeconds: 15
timeoutSeconds: 5
readinessProbe:
exec:
command:
- "/opt/zookeeper/zookeeper_healthcheck.sh"
initialDelaySeconds: 15
timeoutSeconds: 5
volumeClaimTemplates:
- metadata:
name: zookeeper-storage
Expand Down
4 changes: 2 additions & 2 deletions zookeeper/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM fedora:26

RUN dnf -y install java-1.8.0-openjdk-headless gettext hostname && dnf clean all -y
RUN dnf -y install java-1.8.0-openjdk-headless gettext hostname nmap-ncat && dnf clean all -y

# set Kafka home folder
ENV ZOOKEEPER_HOME=/opt/zookeeper
Expand Down Expand Up @@ -32,7 +32,7 @@ EXPOSE 2181 2888 3888
# copy template configuration files
COPY ./config/zookeeper.properties.template $ZOOKEEPER_HOME/config/
# copy scripts for starting Kafka and Zookeeper
COPY ./scripts/zookeeper_run.sh $ZOOKEEPER_HOME
COPY ./scripts/ $ZOOKEEPER_HOME

USER zookeeper:zookeeper

Expand Down
8 changes: 8 additions & 0 deletions zookeeper/scripts/zookeeper_healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

OK=$(echo ruok | nc 127.0.0.1 2181)
if [ "$OK" == "imok" ]; then
exit 0
else
exit 1
fi

0 comments on commit 6f37b67

Please sign in to comment.