• Stars
    star
    190
  • Rank 203,739 (Top 5 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Integrates Marathon apps with Consul service discovery.

marathon-consul Build StatusΒ Coverage StatusΒ Go Report CardΒ Download latest version

We no longer develop this project. If you'd like to take over and continue its maintenance, please fork this repository and let us know by Github issues.

Register Marathon Tasks as Consul Services for service discovery.

marathon-consul takes information provided by the Marathon event bus and forwards it to Consul agents. It also re-syncs all the information from Marathon to Consul on startup and repeats it with given interval.

Note: In the future release Event Bus (callbacks) will be considered deprecated and eventually removed in favor of Event Stream (SSE). Right now marathon-consul is supporting both solutions. SSE is provided as experimental feature, disabled by default (more).

Code

This project is based on

Differences

  • CiscoCloud/marathon-consul copies application information to Consul KV while allegro/marathon-consul registers tasks as Consul services (it is more similar to CiscoCloud/mesos-consul)
  • CiscoCloud/mesos-consul uses polling while allegro/marathon-consul uses Marathon's event bus to detect changes
  • CiscoCloud/marathon-consul is no longer developed (see comment)

Installation

Installing from source code

To simply compile and run the source code:

go run main.go [options]

To run the tests:

make test

To build the binary:

make build

Installing from binary distribution

Binary distribution of marathon-consul can be downloaded directly from the releases page. Download the build dedicated to your OS. After unpacking the archive, run marathon-consul binary. You can also add some options, for example:

marathon-consul --marathon-location=marathon.service.consul:8080 --sync-interval=5m --log-level=debug

Installing via APT package manager

If you are a Debian/Ubuntu user, you can easily install marathon-consul as a deb package using APT package manager. Both upstart and systemd service managers are supported. All releases are published as deb packages to our repository at Bintray.

To install marathon-consul with apt-get, simply follow the instructions:

# add our public key to apt
curl -s https://bintray.com/user/downloadSubjectPublicKey?username=allegro | sudo apt-key add -
# add the repository url
echo "deb http://dl.bintray.com/v1/content/allegro/deb /" | sudo tee /etc/apt/sources.list.d/marathon-consul.list
# update apt cache
sudo apt-get -y update
# install latest release of marathon-consul
sudo apt-get -qy install marathon-consul

Run it with service marathon-consul start. The configuration file is located at /etc/marathon-consul.d/config.json.

Installing with Docker

To build docker image run

make docker

Then you can run it with

docker run -d -P allegro/marathon-consul [options]

If you want to use SSL you will need to expose cert store to Docker. The Following line is only example, your cert store might be different depending on your system.

docker run '/etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt' -P  allegro/marathon-consul

Usage

Marathon masters

  • marathon-consul should be installed on all Marathon masters

Mesos agents

  • Consul Agents should be available on every Mesos agent.
  • Tasks will be registered at the Mesos slave they run on.

Tagging tasks

  • Task labels are used by marathon-consul to register tasks in Consul.
  • Only tasks which are labeled as consul will be registered in Consul. If the consul label is left blank like "consul": "", the task will be registered with the app name by default. A different name can be provided as the label's value, e.g. "consul": "customName". As an exception to this rule, for backward compatibility with the 0.3.x branch, a value of true is resolved to the default name.
  "id": "my-new-app",
  "labels": {
    "consul": ""
  }
  • Only services with tag specified by consul-tag property will be maintained. By default, "consul-tag": "marathon" is automatically added when the task is registered.
  • Labels with a value of tag are converted to consul-tags, and appear in Consul as ServiceTags.
  • For example, we can set these tags in an app definition like:
  "id": "my-new-app",
  "labels": {
    "consul": "",
    "varnish": "tag",
    "metrics": "tag"
  }
  • If marathon-consul registers the app with Consul, we can then query Consul and see these tags appear:
curl -X GET http://localhost:8500/v1/catalog/service/my-new-app
...
"ServiceName": "my-new-app",
"ServiceTags": [
  "marathon",
  "varnish",
  "metrics",
  "marathon-task:my-new-app.6a95bb03-6ad3-11e6-beaf-080027a7aca0"
],

  • Every service registration contains an additional tag marathon-task specifying the Marathon task id related to this registration.
  • If there are multiple ports in use for the same app, note that only the first one will be registered by marathon-consul in Consul.

If you need to register your task under multiple ports, refer to Advanced usage section below.

Task healthchecks

  • At least one HTTP healthcheck should be defined for a task. The task is registered when Marathon marks it as alive.
  • The provided HTTP healthcheck will be transferred to Consul.
  • See this for more details.

Command healthchecks

Healthchecks commands are registered in Consul with a simple variable substitution.

  • $HOST is replaced by task hostname.
  • $PORT0, $PORT1... are replaced by port number defined in task.

Using a special shell syntax can break this variable substitution ($HOST, ${PORT0} ...)

Sync

  • The scheduled Marathon-consul sync may run in two modes:
    • Only on node that is the current Marathon-leader, marathon-leader parameter should be set to hostname:port the current node appears in the Marathon cluster. This mode is enabled by default and the marathon-leader property is set to the hostname resolved by OS. Note that there is a difference between marathon-leader and marathon-location: marathon-leader is used for node leadership detection (should be set to cluster-wide node name), while marathon-location is used for connection purpose (may be set to localhost)
    • On every node, sync-force parameter should be set to true
  • If marathon-consul fails on startup sync and you see following error "Can't get Consul services: No Consul client available in agents cache" it may be caused by empty consul agents cache. If this occurs try configuring --consul-local-agent-host to Consul Master or Consul agent.

Options

Argument Default Description
config-file Path to a JSON file to read configuration from. Note: Will override options set earlier on the command line
consul-auth false Use Consul with authentication
consul-auth-password The basic authentication password
consul-auth-username The basic authentication username
consul-enable-tag-override false Disable the anti-entropy feature for all services
consul-ignored-healthchecks A comma separated blacklist of Marathon health check types that will not be migrated to Consul, e.g. command,tcp
consul-local-agent-host Consul Agent hostname or IP that should be used for startup sync and service listing operations
consul-name-separator . Separator used to create default service name for Consul
consul-get-services-retry 3 Number of retries on failure when performing requests to Consul. Each retry uses different cached agent
consul-max-agent-failures 3 Max number of consecutive request failures for agent before removal from cache
consul-port 8500 Consul port
consul-ssl false Use HTTPS when talking to Consul
consul-ssl-ca-cert Path to a CA certificate file, containing one or more CA certificates to use to validate the certificate sent by the Consul server to us
consul-ssl-cert Path to an SSL client certificate to use to authenticate to the Consul server
consul-ssl-verify true Verify certificates when connecting via SSL
consul-tag marathon Common tag name added to every service registered in Consul, should be unique for every Marathon-cluster connected to Consul
consul-timeout 3s Time limit for requests made by the Consul HTTP client. A Timeout of zero means no timeout
consul-token The Consul ACL token
events-queue-size 1000 Size of events queue
event-max-size 4096 Maximum size of event to process (bytes)
listen :4000 Accept connections at this address
log-file Save logs to file (e.g.: /var/log/marathon-consul.log). If empty logs are published to STDERR
log-format text Log format: JSON, text
log-level info Log level: panic, fatal, error, warn, info, or debug
marathon-location localhost:8080 Marathon URL
marathon-password Marathon password for basic auth
marathon-protocol http Marathon protocol (http or https)
marathon-ssl-verify true Verify certificates when connecting via SSL
marathon-timeout 30s Time limit for requests made by the Marathon HTTP client. A Timeout of zero means no timeout
marathon-username Marathon username for basic auth
marathon-leader Marathon cluster-wide node name (defaults to :8080), the some leader specific calls will be made only if the specified node is the current Marathon-leader. Set to * to always act like a Leader.
metrics-interval 30s Metrics reporting interval
metrics-location Graphite URL (used when metrics-target is set to graphite)
metrics-prefix default Metrics prefix (default is resolved to .<app_name>
metrics-target stdout Metrics destination stdout or graphite (empty string disables metrics)
sentry-dsn Sentry DSN. If it's not set sentry will be disabled
sentry-env Sentry environment
sentry-level error Sentry alerting level (info
sentry-timeout 1s Sentry hook initialization timeout
sse-retries 0 Number of times to recover SSE stream.
sse-retry-backoff 0s Configuration of initial time between retries to recover SSE stream.
sync-enabled true Enable Marathon-consul scheduled sync
sync-force false Force leadership-independent Marathon-consul sync (run always)
sync-interval 15m0s Marathon-consul sync interval
workers-pool-size 10 Number of concurrent workers processing events

Endpoints

Endpoint Description
/health healthcheck - returns OK

Advanced usage

Register under multiple ports

If you need to map your Marathon task into multiple service registrations in Consul, you can configure marathon-consul via Marathon's portDefinitions:

  "id": "my-new-app",
  "labels": {
    "consul": "",
    "common-tag": "tag"
  },
  "portDefinitions": [
    {
      "labels": {
        "consul": "my-app-custom-name"
      }
    },
    {
      "labels": {
        "consul": "my-app-other-name",
        "specific-tag": "tag"
      }
    }
  ]

This configuration would result in two service registrations:

curl -X GET http://localhost:8500/v1/catalog/service/my-app-custom-name
...
"ServiceName": "my-app-custom-name",
"ServiceTags": [
  "marathon",
  "common-tag",
  "marathon-task:my-new-app.6a95bb03-6ad3-11e6-beaf-080027a7aca0"
],
"ServicePort": 31292,
...

curl -X GET http://localhost:8500/v1/catalog/service/my-app-other-name
...
"ServiceName": "my-app-other-name",
"ServiceTags": [
  "marathon",
  "common-tag",
  "specific-tag",
  "marathon-task:my-new-app.6a95bb03-6ad3-11e6-beaf-080027a7aca0"
],
"ServicePort": 31293,
...

If any port definition contains the consul label, then advanced configuration mode is enabled. As a result, only the ports containing this label are registered, under the name specified as the label's value – with empty value resolved to default name. Names don't have to be unique – you can have multiple registrations under the same name, but on different ports, perhaps with different tags. Note that the consul label still needs to be present in the top-level application labels, even though its value won't have any effect.

Tags configured in the top-level application labels will be added to all registrations. Tags configured in the port definition labels will be added only to corresponding registrations.

All registrations share the same marathon-task tag.

Migration to version 1.x.x

Until 1.x.x marathon-consul would register services in Consul with registration id equal to related Marathon task id. Since 1.x.x registration ids are different and an additional tag, marathon-task, is added to each registration.

If you update marathon-consul from version 0.x.x to 1.x.x, expect the synchronization phase during the first startup to reregister all healthy services managed by marathon-consul to the new format. Unhealthy services will get deregistered in the process.

SSE Support

While using SSE please consider:

  • SSE is using Web module config for queues, event sizes, in the future will be moved to sse module,
  • SSE is using marathon-leader config for determining current leader, when this value match leader returned by marathon (/v2/leader endpoint) then SSE is started on this instance,
  • when enabled SSE is spawning its own own set of workers and separated dispatcher,
  • be advised to disable marathon callback subscription when enabling SSE, otherwise it might result in doubling registers and deregisers.

HTTP callbacks support

Marathon-Consul does not support HTTP callbacks. Marathon deprecated support for HTTP callbacks in 1.4. This mechanism is no longer available starting from Marathon 1.5.

Known limitations

The following section describes known limitations in marathon-consul.

  • In Marathon when a deployment changing the application's service name (by changing its labels) is being stopped, it changes app's configuration anyway. This means we loose the link between the app and the services registered with the old name in Consul. Later on, if another deployment takes place, new services are registered with a new name, the old ones are not being deregistered though. A scheduled sync is required to wipe them out.

Release

To release new version of marathon-consul follow steps:

  1. Commit all changes you need for release to master branch.
  2. git checkout master
  3. git checkout -b release/<version> e.g., git checkout -b release/1.3.1
  4. make version v=<version> e.g., make version v=1.3.1
  5. git push
  6. Create pull request from branch release/<version> to master.
  7. Once pull request gets merged put tag on this commit (remember to update your master with git pull) git tag <version> -f e.g., git tag 1.3.1 -f. Create annotated tag with release notes in it.
  8. Travis will automatically prepare github release from tag on master. Go there and update release notes.
  9. Copy github release to bintray.

License

Marathon-consul is released under the Apache 2.0 license (see LICENSE)

More Repositories

1

bigcache

Efficient cache for gigabytes of data written in Go.
Go
7,508
star
2

ralph

Ralph is the CMDB / Asset Management system for data center and back office hardware.
Python
2,200
star
3

tipboard

Tipboard - in-house, tasty, local dashboarding system
JavaScript
1,106
star
4

php-protobuf

PHP Protobuf - Google's Protocol Buffers for PHP
PHP
911
star
5

allRank

allRank is a framework for training learning-to-rank neural models based on PyTorch.
Python
842
star
6

hermes

Fast and reliable message broker built on top of Kafka.
Java
808
star
7

turnilo

Business intelligence, data exploration and visualization web application for Druid, formerly known as Swiv and Pivot
TypeScript
725
star
8

axion-release-plugin

Gradle release & version management plugin.
Groovy
556
star
9

node-worker-nodes

A node.js library to run cpu-intensive tasks in a separate processes and not block the event loop.
JavaScript
489
star
10

typescript-strict-plugin

Typescript plugin that allows turning on strict mode in specific files or directories.
TypeScript
337
star
11

json-avro-converter

JSON to Avro conversion tool designed to make migration to Avro easier.
Groovy
275
star
12

embedded-elasticsearch

Tool that ease up creation of integration tests with Elasticsearch
Java
269
star
13

vaas

VaaS
Python
229
star
14

grunt-maven-plugin

Grunt + Maven integration done right
Java
213
star
15

allegro-api

Issue tracker and wiki for Allegro REST API
212
star
16

tradukisto

A Java i18n library created to convert numbers to their word representations.
Groovy
203
star
17

restapi-guideline

Allegro REST API Guideline.
CSS
183
star
18

bigflow

A Python framework for data processing on GCP.
Python
116
star
19

handlebars-spring-boot-starter

Spring Boot auto-configuration for Handlebars
Groovy
109
star
20

envoy-control

Envoy Control is a platform-agnostic, production-ready Control Plane for Service Mesh based on Envoy Proxy.
Kotlin
98
star
21

akubra

Simple solution to keep a independent S3 storages in sync
Go
86
star
22

elasticsearch-analysis-morfologik

Morfologik Polish Lemmatizer plugin for Elasticsearch
Java
83
star
23

ecto-cursor-based-stream

Elixir library that allows for cursor-based streaming of Ecto records, that does not require database transaction.
Elixir
81
star
24

allms

A versatile and powerful library designed to streamline the process of querying LLMs
Python
70
star
25

opel

OPEL - asynchronous expression language
Java
68
star
26

HerBERT

HerBERT is a BERT-based Language Model trained on Polish Corpora using only MLM objective with dynamic masking of whole words.
64
star
27

fogger

Fogger - a library to create blurred background under Android's UI elements
Java
60
star
28

mesos-executor

Customizable Apache Mesos task executor
Go
49
star
29

json-logic-kmp

Kotlin multiplatform JsonLogic expressions evaluation engine. Targets iOS and JVM (also Android).
Kotlin
49
star
30

elasticsearch-reindex-tool

Elasticsearch reindexing tool.
Java
45
star
31

selena

SELENA is a tool used to test website performance by measuring response times or verifying the content of replies.
JavaScript
45
star
32

kafka-offset-monitor-graphite

Graphite reporter for Kafka Offset Monitor.
Scala
44
star
33

dotnet-utils

C#
37
star
34

cassandra-modeling-kata

Cassandra Modeling Kata
Java
36
star
35

mongo-migration-stream

Tool for online migrations of MongoDB databases.
Kotlin
33
star
36

swift-junit

A Swift library for creating JUnit XML test results that can be interpreted by tools such as Bamboo or Jenkins. Macos and Linux ready.
Swift
29
star
37

slinger

Slinger - deep linking library for Android
Java
29
star
38

django-powerdns-dnssec

Django application managing PowerDNS database
Python
27
star
39

ralph-cli

Command-line interface for the Ralph system.
Go
26
star
40

allegro.tech

TypeScript
23
star
41

hacktoberfest-dashboard

Allegro Hactoberfest activity dashboard
TypeScript
23
star
42

klejbenchmark-baselines

Fine-tuning scripts for evaluating transformer-based models on KLEJ benchmark.
Python
23
star
43

quanta

Fast image optimization as a service, based on mozjpeg, written in Swift
C
21
star
44

bigcache-bench

Benchmarks for BigCache project
Go
20
star
45

pyhermes

The Python interface to the Hermes message broker.
Python
19
star
46

swiftbox

SwiftBox is a package that helps building Swift/Vapor microservices.
Swift
19
star
47

consul-registration-hook

Hook that can be used for synchronous registration and deregistration in Consul discovery service on Kubernetes or Mesos cluster with Allegro executor
Go
18
star
48

marathon-appcop

Marathon applications law enforcement
Go
18
star
49

leader-only-spring-boot-starter

Java
17
star
50

newrelic-gradle-plugin

Newrelic Gradle plugin.
Groovy
17
star
51

map-with-indifferent-access

Elixir
17
star
52

grunt-maven-npm

npm tasks for grunt-maven-plugin 1.2+
JavaScript
16
star
53

redux-storage-decorator-engines

Composing decorator for redux-storage to use different storage types
JavaScript
15
star
54

spunit

Spunit – Spock elegance in Kotlin JUnit 5 tests
Kotlin
14
star
55

cosmosdb-utils

A collection of useful Azure CosmosDb SDK v3 extensions and utilities, developed as part of Allegro Pay product.
C#
13
star
56

envoy-perf-pprof

Convenient Envoy on-CPU performance analysis with perf and pprof.
Dockerfile
13
star
57

dotnet-sdk

C#
12
star
58

prometheus-net-metrics

C#
12
star
59

camus-compressor

Camus Compressor merges files created by Camus and saves them in a compressed format.
Java
12
star
60

blog

HTML
11
star
61

consul-recipes

Java library for interacting with Consul.
Java
11
star
62

ralph_pricing

A pricing module for Ralph
Python
11
star
63

solr-fast-collapsing-query-parser

Java
9
star
64

klejbenchmark-allegroreviews

Allegro Reviews is a sentiment analysis dataset, consisting of 11,588 product reviews written in Polish and extracted from Allegro.pl - a popular e-commerce marketplace.
9
star
65

inkpy-jinja

Generate PDF documents from ODT templates.
Python
8
star
66

allegro-tech-labs-microservices

Allegro Tech Labs Microservices workshop materials
Java
8
star
67

TypedListAdapter

Kotlin
7
star
68

logextractx

Python
7
star
69

django-bob

Django bob is a set of django helpers, widgets and form filters for Ralph DCIM/CMDB project .
JavaScript
7
star
70

solr-ids-export-plugin

Java
6
star
71

toper

PHP Rest client based on popular Guzzle Rest Client.
PHP
6
star
72

atm-event-app

ATM event application
JavaScript
5
star
73

application-insights

5
star
74

graphql-extended-audit-intstrumentation

Java
5
star
75

votakvot

Python
5
star
76

banana-split

JavaScript
5
star
77

conformal-prediction-wut

Jupyter Notebook
5
star
78

AlleNoise

Python
4
star
79

warsztaty-podstawy-ml-03-2019

Machine learning basics workshop
Jupyter Notebook
4
star
80

selena-agent

Agent for Selena
Python
4
star
81

json-cache

Java
3
star
82

swiftbox-config

Swift
3
star
83

vaas-registration-hook

Go
3
star
84

braincode

HTML
3
star
85

oauth-mock

Kotlin
3
star
86

parallel-test-execution-workshop

Resources for Parallel test execution workshop
Groovy
3
star
87

swiftbox-metrics-statsd

Swift
2
star
88

atm-hero-generator

JavaScript
2
star
89

client-side-logic-dsl

Kotlin
2
star
90

eslint-plugin-test-comments

TypeScript
2
star
91

couchbase-commons

Kotlin
1
star
92

hermes-page

Hermes OpenSource page.
HTML
1
star
93

ml

TypeScript
1
star
94

swiftbox-logging

Swift
1
star
95

podcast.allegro.tech

CSS
1
star
96

axion-release-example

Kotlin
1
star
97

jobs-conf

allegro.tech jobs postings
HTML
1
star
98

allegro-tech-labs-iot

Allegro Tech Labs IoT workshop materials
Python
1
star
99

versionlens.nvim

1
star