Skip to content

Commit

Permalink
Merge pull request #353 from saagie/feature/mesos
Browse files Browse the repository at this point in the history
add mesos provider inspired by mesos-dns & marathon provider
  • Loading branch information
emilevauge authored Jul 20, 2016
2 parents 61b2231 + 5afcf17 commit 8e333d0
Show file tree
Hide file tree
Showing 13 changed files with 1,019 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


Træfɪk is a modern HTTP reverse proxy and load balancer made to deploy microservices with ease.
It supports several backends ([Docker](https://www.docker.com/), [Swarm](https://docs.docker.com/swarm), [Mesos/Marathon](https://mesosphere.github.io/marathon/), [Kubernetes](http://kubernetes.io/), [Consul](https://www.consul.io/), [Etcd](https://coreos.com/etcd/), [Zookeeper](https://zookeeper.apache.org), [BoltDB](https://github.com/boltdb/bolt), Rest API, file...) to manage its configuration automatically and dynamically.
It supports several backends ([Docker](https://www.docker.com/), [Swarm](https://docs.docker.com/swarm), [Mesos/Marathon](https://mesosphere.github.io/marathon/), [Mesos](https://github.com/apache/mesos), [Kubernetes](http://kubernetes.io/), [Consul](https://www.consul.io/), [Etcd](https://coreos.com/etcd/), [Zookeeper](https://zookeeper.apache.org), [BoltDB](https://github.com/boltdb/bolt), Rest API, file...) to manage its configuration automatically and dynamically.

## Overview

Expand Down
9 changes: 9 additions & 0 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type GlobalConfiguration struct {
Zookeeper *provider.Zookepper `description:"Enable Zookeeper backend"`
Boltdb *provider.BoltDb `description:"Enable Boltdb backend"`
Kubernetes *provider.Kubernetes `description:"Enable Kubernetes backend"`
Mesos *provider.Mesos `description:"Enable Mesos backend"`
}

// DefaultEntryPoints holds default entry points
Expand Down Expand Up @@ -277,6 +278,13 @@ func NewTraefikDefaultPointersConfiguration() *TraefikConfiguration {
defaultKubernetes.LabelSelector = ""
defaultKubernetes.Constraints = []types.Constraint{}

// default Mesos
var defaultMesos provider.Mesos
defaultMesos.Watch = true
defaultMesos.Endpoint = "http://127.0.0.1:5050"
defaultMesos.ExposedByDefault = true
defaultMesos.Constraints = []types.Constraint{}

defaultConfiguration := GlobalConfiguration{
Docker: &defaultDocker,
File: &defaultFile,
Expand All @@ -288,6 +296,7 @@ func NewTraefikDefaultPointersConfiguration() *TraefikConfiguration {
Zookeeper: &defaultZookeeper,
Boltdb: &defaultBoltDb,
Kubernetes: &defaultKubernetes,
Mesos: &defaultMesos,
Retry: &Retry{},
}
return &TraefikConfiguration{
Expand Down
32 changes: 32 additions & 0 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,16 @@ import:
- package: github.com/mattn/go-shellwords
- package: github.com/vdemeester/shakers
- package: github.com/ryanuber/go-glob
- package: github.com/mesos/mesos-go
subpackages:
- mesosproto
- mesos
- upid
- mesosutil
- detector
- package: github.com/jarcoal/httpmock
- package: github.com/mesosphere/mesos-dns
vcs: git
repo: https://github.com/containous/mesos-dns.git
version: b47dc4c19f215e98da687b15b4c64e70f629bea5
- package: github.com/tv42/zbase32
9 changes: 9 additions & 0 deletions integration/fixtures/mesos/simple.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defaultEntryPoints = ["http"]

[entryPoints]
[entryPoints.http]
address = ":8000"

logLevel = "DEBUG"

[mesos]
1 change: 1 addition & 0 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func init() {
check.Suite(&EtcdSuite{})
check.Suite(&MarathonSuite{})
check.Suite(&ConstraintSuite{})
check.Suite(&MesosSuite{})
}

var traefikBinary = "../dist/traefik"
Expand Down
33 changes: 33 additions & 0 deletions integration/mesos_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"net/http"
"os/exec"
"time"

"github.com/go-check/check"

checker "github.com/vdemeester/shakers"
)

// Mesos test suites (using libcompose)
type MesosSuite struct{ BaseSuite }

func (s *MesosSuite) SetUpSuite(c *check.C) {
s.createComposeProject(c, "mesos")
}

func (s *MesosSuite) TestSimpleConfiguration(c *check.C) {
cmd := exec.Command(traefikBinary, "--configFile=fixtures/mesos/simple.toml")
err := cmd.Start()
c.Assert(err, checker.IsNil)
defer cmd.Process.Kill()

time.Sleep(500 * time.Millisecond)
// TODO validate : run on 80
resp, err := http.Get("http://127.0.0.1:8000/")

// Expected a 404 as we did not configure anything
c.Assert(err, checker.IsNil)
c.Assert(resp.StatusCode, checker.Equals, 404)
}
34 changes: 34 additions & 0 deletions integration/resources/compose/mesos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
zk:
image: bobrik/zookeeper
net: host
environment:
ZK_CONFIG: tickTime=2000,initLimit=10,syncLimit=5,maxClientCnxns=128,forceSync=no,clientPort=2181
ZK_ID: " 1"

master:
image: mesosphere/mesos-master:0.28.1-2.0.20.ubuntu1404
net: host
environment:
MESOS_ZK: zk://127.0.0.1:2181/mesos
MESOS_HOSTNAME: 127.0.0.1
MESOS_IP: 127.0.0.1
MESOS_QUORUM: " 1"
MESOS_CLUSTER: docker-compose
MESOS_WORK_DIR: /var/lib/mesos

slave:
image: mesosphere/mesos-slave:0.28.1-2.0.20.ubuntu1404
net: host
pid: host
privileged: true
environment:
MESOS_MASTER: zk://127.0.0.1:2181/mesos
MESOS_HOSTNAME: 127.0.0.1
MESOS_IP: 127.0.0.1
MESOS_CONTAINERIZERS: docker,mesos
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup
- /usr/bin/docker:/usr/bin/docker:ro
- /usr/lib/x86_64-linux-gnu/libapparmor.so.1:/usr/lib/x86_64-linux-gnu/libapparmor.so.1:ro
- /var/run/docker.sock:/var/run/docker.sock
- /lib/x86_64-linux-gnu/libsystemd-journal.so.0:/lib/x86_64-linux-gnu/libsystemd-journal.so.0
Loading

0 comments on commit 8e333d0

Please sign in to comment.