clusterduck

0.1.110 • Public • Published

clusterduck

total downloads of clusterduck clusterduck's License latest version of clusterduck

A better way to supervise your clusters and services.

The project is recently hatched and in the stage of active development.

Clusterduck is a robust solution for real-time distributed monitoring and self-healing clustering.

  • Raft consensus algorithm. Ducks love them rafts 😉 liferaft is running over a robust TLS transport with peer discovery and HMAC-based authentication.

  • Health checks, real-time and voting-based.

  • Self-healing clusters. When the number of active nodes in a cluster falls below a given threshold, new nodes will be started automatically on the least loaded server(s) in a split second. Spare pools are supported.

  • Events and triggers Just about everything is an event that you can hook up your trigger to.

  • KISS. Hacking up your own plugin is definitely not a rocket science.

Featured extensions

🚀 clusterduck-dashboard — A full-fledged dashboard built with React and Websocket.

clusterduck-redis — Redis health checks and envoy-based balancing

🚀 clusterduck-http — HTTP/Websocket health checks and haproxy/nginx support.

Table Of Contents

Installation

Node 15.x is recommended.

npm i -g clusterduck

Alternatively, you can clone the repo and link the dependencies which is useful for development purposes:

git clone git@github.com:kakserpom/clusterduck.git
cd clusterduck
node link

TLS

If you want to enable TLS for Raft, run this to generate certificates:

clusterduck gen-tls

Command-line interface

Run the clusterduck command to see if it all works for you.

If you want to daemonize it, run clusterduck -d

If you want to stop a running daemon, run clusterduck stop

For debugging purposes use DEBUG environmental variable: DEBUG=* clusterduck

Configuration

The default config file path is /etc/clusterduck/clusterduck.yaml

Clusters

Let's define a Redis cluster named my_redis_cluster:

clusters:
  
  my_redis_cluster:
    type: clusterduck-redis

Nodes

Then let's define some nodes:

    # List of nodes
    nodes:
      - addr: 127.0.0.1:6379
      - addr: 127.0.0.1:6380

Note that you can omit this altogether if you want to only add nodes dynamically.

Health checks

Now let's set up a simple health check.

    health_checks:
      - type: basic
        timeout: 1s
        interval: 10s
        interval_after_fail: 1s
        commands:
          - [ 'SET', 'x', 'y' ]

Now every 10 secs each node in the cluster will get checked on. If the check fails, a retry happens after 1 sec.

Triggers

Now let's live export the list of active nodes:

    triggers:
      - on: [ active ]
        do:
          - type: shell
            cwd: /tmp
            commands:
              - "echo $nodes_active_addrs > active_nodes.json"

This will make sure that /tmp/nodes_list always contains a current list of alive nodes.

Events

Cluster events

Event Description
changed Set of nodes has changed

Node events

Event Description
state Node state has changed

Transports

transports:

Raft

  - type: raft
    address: tls://127.0.0.1:9911
    bootstrap: [ tls://127.0.0.1:9910 ]
Parameter Description
address * Address to listen
tls Path pattern to key/cert files. Default is clusterduck.%s (relative to the config file directory)
bootstrap List of node addresses to connect with.

Clusterduck instances will exchange peers and update bootstrap accordingly, but initial address is necessary.

HTTP

  - type: http
    listen: 8880
Parameter Description
listen Port to listen

Roadmap

  • CLI
  • Live config updates (i.e. more Commands)
  • REST API

Transports

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.1102latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.1102
0.1.1090
0.1.1080
0.1.1070
0.1.1060
0.1.1050
0.1.1040
0.1.1030
0.1.1020
0.1.1010
0.1.1000
0.1.990
0.1.980
0.1.970
0.1.960
0.1.950
0.1.940
0.1.930
0.1.921
0.1.910
0.1.900
0.1.890
0.1.880
0.1.870
0.1.860
0.1.850
0.1.840
0.1.830
0.1.820
0.1.810
0.1.800
0.1.780
0.1.770
0.1.760
0.1.750
0.1.740
0.1.730
0.1.720
0.1.710
0.1.700
0.1.690
0.1.680
0.1.670
0.1.661
0.1.650
0.1.630
0.1.620
0.1.610
0.1.600
0.1.590
0.1.580
0.1.570
0.1.560
0.1.550
0.1.540
0.1.530
0.1.520
0.1.510
0.1.500
0.1.490
0.1.480
0.1.470
0.1.460
0.1.453
0.1.440
0.1.430
0.1.420
0.1.411
0.1.400
0.1.390
0.1.380
0.1.370
0.1.360
0.1.350
0.1.340
0.1.330
0.1.320
0.1.310
0.1.300
0.1.290
0.1.280
0.1.270
0.1.260
0.1.250
0.1.240
0.1.230
0.1.220
0.1.210
0.1.201
0.1.190
0.1.180
0.1.170
0.1.160
0.1.150
0.1.140
0.1.130
0.1.121
0.1.110
0.1.100
0.1.90
0.1.80
0.1.70
0.1.60
0.1.50
0.1.40
0.1.30
0.1.20
0.1.10

Package Sidebar

Install

npm i clusterduck

Weekly Downloads

10

Version

0.1.110

License

GPL-3.0-only

Unpacked Size

163 kB

Total Files

39

Last publish

Collaborators

  • kakserpom