Coder Social home page Coder Social logo

fabric8-zookeeper-docker's Introduction

Fabric8 - ZooKeeper Docker Image

A ZooKeeper Docker Image for use with Kubernetes.

The image supports the following ZooKeeper modes:

  • Standalone
  • Clustered

Standalone Mode

To start the image in standalone mode you can simply use:

docker run fabric8/zookeeper

Clustered Mode

To start the image in clustered mode you need to specify a couple of environment variables for the container.

Environment Variable Description
SERVER_ID The id of the server
MAX_SERVERS The number of servers in the ensemble

Each container started with both of the above variables will use the following env variable setup:

server.1=zookeeper-1:2888:3888
server.2=zookeeper-2:2888:3888
server.3=zookeeper-3:2888:3888
...
server.N=zookeeper-N:2888:3888

Ensuring that zookeeper-1, zookeeper-2 ... zookeeper-N can be resolved is beyond the scope of this image. You can use DNS, or Kubernetes services, etc depending on your environment (see below).

Inside Kubernetes

Inside Kubernetes you can use a pod setup that looks like:

{
  "kind": "Pod",
  "apiVersion": "v1beta3",
  "metadata": {
    "name": "zookeeper-1",
    "labels": {
      "name": "zookeeper",
      "server-id": "1"
    }
  },
  "spec": {
    "containers": [
      {
        "name": "server",
        "image": "fabric8/zookeeper",
        "env":[
          { "name": "SERVER_ID", "value": "1" },
          { "name": "MAX_SERVERS", "value": "3" }
        ],
        "ports":[
          {
            "containerPort": 2181
          },
          {
            "containerPort": 2888
          },
          {
            "containerPort": 3888
          }
        ]
      }
    ]
  }

In the example above we are creating a pod that creates a container using this image. The container is configured to use the environment variable required for a clustered setup. Last but not least pod is carefully named (as zookeeper-${SERVER_ID}) so that the other zookeeper servers can easily find it by hostname.

fabric8-zookeeper-docker's People

Contributors

iocanel avatar jimmidyson avatar mfojtik avatar msprunck avatar mulloymorrow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fabric8-zookeeper-docker's Issues

Workaround kubernetes / zookeeper gaps

ZooKeeper assumes that for each zookeeper server the election and the peer port use the same host ip.
On the other hand later versions of kubernetes use dedicated internal ip per service.

So the current image is not usable under later kubernetes versions.

It would be awesome if we could have a workaround this limitation until kubernetes/kubernetes#1802 is resolved.

The easiest workaround would be to use port mapping of local ports to the actual server ports.

License?

Hey, can you assign a license to the code available in this repository? I need to know its licensing before I can use it in a project. Plenty of chill licenses are available here: http://opensource.org/licenses

Thanks!

Cannot start Zookeeper container

Starting the container as docker run fabric8/zookeeper gives the following error:

Status: Downloaded newer image for fabric8/zookeeper:latest
JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
2015-05-20 21:14:00,118 [myid:] - INFO  [main:QuorumPeerConfig@103] - Reading configuration from: /opt/zookeeper/bin/../conf/zoo.cfg
2015-05-20 21:14:00,122 [myid:] - ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing /opt/zookeeper/bin/../conf/zoo.cfg
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:123)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:101)
    at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)
Caused by: java.lang.NumberFormatException: For input string: ""
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:504)
    at java.lang.Integer.parseInt(Integer.java:527)
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:145)
    at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:119)
    ... 2 more
Invalid config, exiting abnormally

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.