Add basic authentication support in Marathon

This commit is contained in:
emile 2016-01-18 11:52:18 +01:00
parent 707b6f9a95
commit c46ffed846
No known key found for this signature in database
GPG key ID: D808B4C167352E59
4 changed files with 26 additions and 14 deletions

View file

@ -18,9 +18,16 @@ type Marathon struct {
Endpoint string
Domain string
NetworkInterface string
Basic *MarathonBasic
marathonClient lightMarathonClient
}
// MarathonBasic holds basic authentication specific configurations
type MarathonBasic struct {
HTTPBasicAuthUser string
HTTPBasicPassword string
}
type lightMarathonClient interface {
Applications(url.Values) (*marathon.Applications, error)
AllTasks(v url.Values) (*marathon.Tasks, error)
@ -32,6 +39,10 @@ func (provider *Marathon) Provide(configurationChan chan<- types.ConfigMessage)
config := marathon.NewDefaultConfig()
config.URL = provider.Endpoint
config.EventsInterface = provider.NetworkInterface
if provider.Basic != nil {
config.HTTPBasicAuthUser = provider.Basic.HTTPBasicAuthUser
config.HTTPBasicPassword = provider.Basic.HTTPBasicPassword
}
client, err := marathon.NewClient(config)
if err != nil {
log.Errorf("Failed to create a client for marathon, error: %s", err)

View file

@ -6,7 +6,7 @@ zk:
ZK_ID: 1
master:
image: mesosphere/mesos-master:0.23.0-1.0.ubuntu1404
image: mesosphere/mesos-master:0.26.0-0.2.145.ubuntu1404
net: host
environment:
MESOS_ZK: zk://127.0.0.1:2181/mesos
@ -17,7 +17,7 @@ master:
MESOS_WORK_DIR: /var/lib/mesos
slave:
image: mesosphere/mesos-slave:0.23.0-1.0.ubuntu1404
image: mesosphere/mesos-slave:0.26.0-0.2.145.ubuntu1404
net: host
pid: host
privileged: true
@ -33,7 +33,7 @@ slave:
- /var/run/docker.sock:/var/run/docker.sock
marathon:
image: mesosphere/marathon:v0.9.2
image: mesosphere/marathon:v0.13.0
net: host
environment:
MARATHON_MASTER: zk://127.0.0.1:2181/mesos

View file

@ -10,14 +10,7 @@
"network": "BRIDGE",
"portMappings": [
{ "containerPort": 80, "hostPort": 0, "protocol": "tcp" }
],
"parameters": [{
"key": "log-driver",
"value": "gelf"
}, {
"key": "log-opt",
"value": "gelf-address=udp://172.17.42.1:12201"
}]
]
}
},
"healthChecks": [
@ -32,8 +25,6 @@
],
"labels": {
"traefik.weight": "1",
"traefik.protocole": "https",
"traefik.frontend.rule": "Path",
"traefik.frontend.value": "/test"
"traefik.protocole": "http"
}
}

View file

@ -142,6 +142,8 @@
# Enable docker TLS connection
#
# Optional
#
# [docker.tls]
# ca = "/etc/ssl/ca.crt"
# cert = "/etc/ssl/docker.crt"
@ -192,6 +194,14 @@
#
# filename = "marathon.tmpl"
# Enable Marathon basic authentication
#
# Optional
#
# [marathon.basic]
# httpBasicAuthUser = "foo"
# httpBasicPassword = "bar"
################################################################
# Consul KV configuration backend