Openshift online zookeeper from dockerfile pod "Crash loop back off"

1.1k views Asked by At

I want to deploy application on Openshift-origin online (next gen). There will be at least 4 pods communicating via services.

In 1st POD I have to run Zookeeper. So I created POD where my Zookeeper from docker image will be running, but POD's status is: Crash loop back off.

I created new project

oc new-project my-project

I created new app to deploy my zookeeper from docker

oc new-app mciz/zookeeper-docker-infispector --name zookeeper

And the output message was:

--> Found Docker image 51220f2 (11 minutes old) from Docker Hub for "mciz/zookeeper-docker-infispector"

* An image stream will be created as "zookeeper:latest" that will track this image
* This image will be deployed in deployment config "zookeeper"
* Ports 2181/tcp, 2888/tcp, 3888/tcp will be load balanced by service "zookeeper"
  * Other containers can access this service through the hostname "zookeeper"
* This image declares volumes and will default to use non-persistent, host-local storage.
  You can add persistent volumes later by running 'volume dc/zookeeper --add ...'
* WARNING: Image "mciz/zookeeper-docker-infispector" runs as the 'root' user which may not be permitted by your cluster administrator

--> Creating resources with label app=zookeeper ...
imagestream "zookeeper" created
deploymentconfig "zookeeper" created
service "zookeeper" created
--> Success
Run 'oc status' to view your app.

Then I ran pods list:

oc get pods

with output:

NAME               READY   STATUS             RESTART      AGE
zookeeper-1-mrgn1  0/1     CrashLoopBackOff   5            5m

Then I ran logs:

 oc logs -p zookeeper-1-mrgn1 

with output:

JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
grep: /opt/zookeeper/bin/../conf/zoo.cfg: No such file or directory
mkdir: can't create directory '': No such file or directory
log4j:WARN No appenders could be found for logger         (org.apache.zookeeper.server.quorum.QuorumPeerConfig).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig     for more info.
Invalid config, exiting abnormally

My dockerfile:

FROM openjdk:8-jre-alpine
MAINTAINER mciz

ARG MIRROR=http://apache.mirrors.pair.com
ARG VERSION=3.4.6

LABEL name="zookeeper" version=$VERSION

RUN apk add --no-cache wget bash \
    && mkdir /opt \
    && wget -q -O - $MIRROR/zookeeper/zookeeper-$VERSION/zookeeper-    $VERSION.tar.gz | tar -xzf - -C /opt \
    && mv /opt/zookeeper-$VERSION /opt/zookeeper \
    && cp /opt/zookeeper/conf/zoo_sample.cfg     /opt/zookeeper/conf/zoo.cfg 

EXPOSE 2181 2888 3888

WORKDIR /opt/zookeeper

VOLUME ["/opt/zookeeper/conf"]

ENTRYPOINT ["/opt/zookeeper/bin/zkServer.sh"]
CMD ["start-foreground"]
1

There are 1 answers

0
Álvaro Pérez Soria On

There is a warning in the new-app command output:

WARNING: Image "mciz/zookeeper-docker-infispector" runs as the 'root' user which may not be permitted by your cluster administrator

You should fix the docker image to not run as root (or tell OpenShift to allow this project containers to run as root).

There is an specific example of Zookeeper image and template that works in Openshift.

https://github.com/openshift/origin/tree/master/examples/zookeeper

Notice the Dockerfile changes to run the container as non root user