Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Zookeeper readiness and liveness check #3 #39

Merged
merged 1 commit into from
Oct 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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