Coder Social home page Coder Social logo

beacon's Introduction

Beacon

Build Status

Beacon pipes container start/stop events to various systems. Currently it supports Docker as its runtime and Amazon SNS as its backend. More runtimes and backends are currently planned.

How It Works

Beacon listens for events on the configured runtime. When an event is receieved it evaluates a filter expression attached to each of the configured backends. The event is processed by each backend whose filter matches the event.

Beacon allows containers to be grouped into services. The runtime is responsible for identifying the service a container is part of.

Building

Beacon uses Make to drive the test and build process.

To test Beacon:

make test

to build Beacon:

make

The build will create a binary called beacon in a newly created bin directory.

Running

Beacon takes a single command line flag: -config. It should be the path to the config file. If not set the default config file is at /etc/beacon.yml.

Config File

The config file is formatted as YAML. It has sections for the runtime (docker) and backends. An example config file is available here.

Runtimes

Currently Beacon supports a single runtime: Docker.

The Docker runtime is configured with a socket, host IP, and label. The socket is of type unix:// or tcp:// and is used to connect to the Docker daemon. Port bindings which listen on 0.0.0.0 are assigned the host IP. Lastly the label is the name of the lable containing the name of the service. Events are ignored for containers which do not have this label.

A config file snippet for Docker:

docker:
  socket: unix:///var/run/docker.sock
  host-ip: 169.254.12.152
  label: service

The Docker runtime can be configured to send stop events for all running containers when Beacon stops. This is done by setting the stop-on-exit value to true:

docker:
  socket: unix:///var/run/docker.sock
  host-ip: 169.254.12.152
  label: service
  stop-on-exit: true

Backends

Currently Beacon supports two backends: sns and debug.

SNS

The sns backend queues events to an AWS SNS topic. The SNS backend is configured with a region and topic ARN.

A config file snippet for SNS:

backends:
- sns:
	region: us-east-1
	topic: arn:aws:sns:us-east-1:698519295917:TestTopic
  filter:
	group: ops

The SNS message is a JSON encoded event. An example follows:

{
	"Action": "start",
	"Container": {
		"ID": "512b64138152",
		"Service": "www",
		"Labels": {
			"service": "www",
			"service_port": "80",
		},
		"Bindings": [
			{
				"HostIP": "169.254.12.152",
				"HostPort": 54698,
				"ContainerPort": 80,
				"Protocol": "tcp"
			}
		]
	}
}

Debug

The debug backend prints events to the log.

A config file snippet for the debug:

backends:
- debug: {}

License

Copyright (c) 2015 Ryan Bourgeois. Licensed under BSD-Modified. See the LICENSE file for a copy of the license.

beacon's People

Contributors

rynbrd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

beacon's Issues

Support TLS to Docker

The underlying Docker client supports TLS but we don't implement that. Do the things to implement that.

Straight up crashed when misconfigured.

Beacon_1 | panic: config failed to parse {hostname: } as string [recovered]
Beacon_1 | panic: config failed to parse {hostname: } as string
Beacon_1 |
Beacon_1 | goroutine 1 [running]:
Beacon_1 | runtime.panic(0x6a7520, 0xc210036ca0)
Beacon_1 | /usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
Beacon_1 | gopkg.in/yaml%2ev1.handleErr(0x7f23e217aae8)
Beacon_1 | /usr/share/go/src/gopkg.in/yaml.v1/yaml.go:28 +0x143
Beacon_1 | runtime.panic(0x6a7520, 0xc210036ca0)
Beacon_1 | /usr/local/go/src/pkg/runtime/panic.c:248 +0x106
Beacon_1 | gopkg.in/BlueDragonX/yamlcfg%2ev1.AssertIsString(0x739bb0, 0x8, 0x0, 0x0)
Beacon_1 | /usr/share/go/src/gopkg.in/BlueDragonX/yamlcfg.v1/errors.go:44 +0xb5
Beacon_1 | gopkg.in/BlueDragonX/yamlcfg%2ev1.GetString(0x6431e0, 0xc2100650f0, 0x739bb0, 0x8, 0x71a6a0, ...)
Beacon_1 | /usr/share/go/src/gopkg.in/BlueDragonX/yamlcfg.v1/parse.go:95 +0xf0
Beacon_1 | main.(_ServiceConfig).SetYAML(0xc210059420, 0x727aa0, 0x7, 0x6431e0, 0xc2100650f0, ...)
Beacon_1 | /tmp/build/src/beacon/config.go:104 +0x198
Beacon_1 | main.(_Config).SetYAML(0xc210059410, 0xc210000360, 0x5, 0x6431e0, 0xc210065060, ...)
Beacon_1 | /tmp/build/src/beacon/config.go:210 +0x24b
Beacon_1 | gopkg.in/yaml%2ev1.func·001()
Beacon_1 | /usr/share/go/src/gopkg.in/yaml.v1/decode.go:221 +0x83
Beacon_1 | gopkg.in/yaml%2ev1.(_decoder).mapping(0x7f23e217aa90, 0xc21004a240, 0x6ed020, 0xc210059410, 0x196, ...)
Beacon_1 | /usr/share/go/src/gopkg.in/yaml.v1/decode.go:503 +0x11a
Beacon_1 | gopkg.in/yaml%2ev1.(_decoder).unmarshal(0x7f23e217aa90, 0xc21004a240, 0x6ed020, 0xc210059410, 0x196, ...)
Beacon_1 | /usr/share/go/src/gopkg.in/yaml.v1/decode.go:261 +0x99
Beacon_1 | gopkg.in/yaml%2ev1.(_decoder).document(0x7f23e217aa90, 0xc21004a1e0, 0x6ed020, 0xc210059410, 0x196, ...)
Beacon_1 | /usr/share/go/src/gopkg.in/yaml.v1/decode.go:273 +0x77
Beacon_1 | gopkg.in/yaml%2ev1.(_decoder).unmarshal(0x7f23e217aa90, 0xc21004a1e0, 0x6ed020, 0xc210059410, 0x196, ...)
Beacon_1 | /usr/share/go/src/gopkg.in/yaml.v1/decode.go:255 +0x67
Beacon_1 | gopkg.in/yaml%2ev1.Unmarshal(0xc21000ba00, 0x69, 0x269, 0x6c4900, 0xc210059410, ...)
Beacon_1 | /usr/share/go/src/gopkg.in/yaml.v1/yaml.go:95 +0x205
Beacon_1 | main.LoadConfig(0x2, 0x722a60, 0x6, 0xc21000ae70, 0x0, ...)
Beacon_1 | /tmp/build/src/beacon/config.go:287 +0x226
Beacon_1 | main.main()
Beacon_1 | /tmp/build/src/beacon/main.go:23 +0x1d4
Beacon_1 |
Beacon_1 | goroutine 3 [runnable]:
Beacon_1 | os/signal.loop()
Beacon_1 | /usr/local/go/src/pkg/os/signal/signal_unix.go:19
Beacon_1 | created by os/signal.init·1
Beacon_1 | /usr/local/go/src/pkg/os/signal/signal_unix.go:27 +0x31

Does not compile, as samalba/dockerclient changed ListContainers API

I don't know extactly how that go-dependency management works, but if I clone and compile today, I get an error:
src/github.com/BlueDragonX/beacon/monitor.go:130: not enough arguments in call to mon.client.ListContainers

AFAICS, the second boolean parameter is missing at the ListContainers call.

Add Dockerfile

I want to run this as a fleet global unit on my CoreOS cluster. A dockerfile or automated build would be sweet!

Log Missing Service Ports

Currently if a container announces itself (via the SERVICES variable) as exposing a service on a particular port and does not actually expose that port then it is silently ignored.

Need better logging to indicate that no exposed port is available and it is being skipped.

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.