Giter Club home page Giter Club logo

zookeeper-operator's Introduction

GolangCI GoDoc Build Status Go Report Card

Overview

zookeeper-operator implements an operator for Zookeeper 3.4.x based on operator-sdk and controller-runtime. It supports creating a zookeeper cluster given a spec containing number of nodes and size of data directory. Persistence is achieved through 'standard' storage class and PersistentVolumeClaim.

Scaling up and down through rolling update is also supported. Dockerfile to build zookeeper also resides in same repo.

Start

# Make sure [operator-sdk](https://github.com/operator-framework/operator-sdk) is installed
# Refer to operator-sdk docs for more and dependencies of operator-sdk.

$ mkdir -p $GOPATH/src/github.com/operator-framework
$ cd $GOPATH/src/github.com/operator-framework
$ git clone https://github.com/operator-framework/operator-sdk
$ cd operator-sdk
$ git checkout master
$ make dep
$ make install



$ mkdir -p $GOPATH/src/github.com/ronin13/
$ cd $GOPATH/src/github.com/ronin13/
$ git clone https://github.com/ronin13/zookeeper-operator
$ cd zookeeper-operator

# Make sure kubectl points to a running k8s cluster (or minikube for a start).
$ minikube start

# Build docker build
$ eval $(minikube docker-env)
$ make -C docker-zookeeper build

# Create accounts for RBAC
$ kubectl create -f deploy/service_account.yaml
$ kubectl create -f deploy/role.yaml
$ kubectl create -f deploy/role_binding.yaml

# Deploy zookeeper CRD
$ kubectl create -f deploy/crds/wnohang_v1alpha1_zookeeper_crd.yaml

# Deploy zookeeper custom resource  (default name is zoos with 3 nodes).
$ kubectl create -f deploy/crds/wnohang_v1alpha1_zookeeper_cr.yaml

# Finally deploy the operator.
$ kubectl create -f deploy/operator.yaml

# See if the cluster is running.

$ kubectl get pods -l app=zoos
NAME     READY   STATUS    RESTARTS   AGE
zoos-0   0/1     Running   0          6s
zoos-1   0/1     Running   0          6s
zoos-2   0/1     Running   0          6s


$ kubectl describe zookeeper.wnohang.net/zoos
Name:         zoos
Namespace:    default
Labels:       <none>
Annotations:  <none>
API Version:  wnohang.net/v1alpha1
Kind:         Zookeeper
Metadata:
  Creation Timestamp:  2019-04-01T22:16:41Z
  Generation:          1
  Resource Version:    184847
  Self Link:           /apis/wnohang.net/v1alpha1/namespaces/default/zookeepers/zoos
  UID:                 d39f11f4-54cb-11e9-8160-08002759e00a
Spec:
  Nodes:  3
Events:   <none>


# Verify that it is running.

$ for x in 0 1 2;do kubectl exec zoos-$x -- sh -c  "echo -n $x' ';  echo mntr  | nc localhost 2181 | grep zk_server_state"; done
0 zk_server_state       follower
1 zk_server_state       follower
2 zk_server_state       leader

# Cleanup
$ kubectl delete -R -f deploy/
$ kubectl delete  statefulsets/zoos pvc/zoos-zoos-{0,1,2} 

# Scaling up/down

$ kubectl edit zookeeper.wnohang.net/zoos
# Bump the nodes of replicas and save.


zookeeper-operator's People

Contributors

ronin13 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.