Code Monkey home page Code Monkey logo

hadiscover's Introduction

hadiscover

This tool generates a HAproxy configuration file based on etcd, and then reloads gracefully HAproxy.

hadiscover is listening on a specific directory in etcd, and for each changes it re-generates the configuration and reloads graceully the server (using the -sf HAproxy flag).

It have been created to be used in parallel of my Dockreg tool which does Docker container registration in etcd (see my blog post).

For more information and for build instruction, please read my post about Service Discovery with HAproxy.

Config file

hadiscover uses a go text template to generate the haproxy configuration. For example:

global
    maxconn 4096

defaults
    log global
    mode    http
    option  httplog
    option  dontlognull
    retries 3
    redispatch
    maxconn 2000
    contimeout  5000
    clitimeout  50000
    srvtimeout  50000

frontend http-in
    bind *:8000
    default_backend http

backend http
{{range .}}     server {{.Name}} {{.Ip}}:{{.Port}} maxconn 32
{{end}}

The backend http part will be replaced by the list of available services retrieved in etcd.

The key name in etcd must have be formatted with the form host:port, for example: http://my-etcd-server:4001/keys/services/192.168.0.1:8000

Command line usage

hadiscover --config templatePath --etcd etcdServersList --ha pathToHAcommand --key etcdKey

Where:

  • templatePath is the path to the configuration template
  • etcdServersList is the list of etcd servers, like --etcd http://localhost:4001
  • pathToHAcommand is the path to the HAproxy executable
  • etcdKey is the key to watch changes for

hadiscover's People

Contributors

adetante avatar scottjbarr avatar irontoby avatar

Watchers

CL.Lam avatar James Cloos 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.