This repository has been archived by the owner on Jun 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21f4672
commit c6f8952
Showing
21 changed files
with
238 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
minimesos/src/main/groovy/com/containersol/minimesos/config/ConsulConfig.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.containersol.minimesos.config; | ||
|
||
public class ConsulConfig extends ContainerConfigBlock implements ContainerConfig { | ||
|
||
public static final String CONSUL_IMAGE_NAME = "consul" | ||
public static final String CONSUL_TAG_NAME = "0.7.1" | ||
|
||
public static final int CONSUL_HTTP_PORT = 8500 | ||
public static final int CONSUL_DNS_PORT = 8600 | ||
|
||
public ConsulConfig() { | ||
imageName = CONSUL_IMAGE_NAME | ||
imageTag = CONSUL_TAG_NAME | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
minimesos/src/main/groovy/com/containersol/minimesos/config/RegistratorConfig.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.containersol.minimesos.config; | ||
|
||
public class RegistratorConfig extends ContainerConfigBlock implements ContainerConfig { | ||
|
||
public static final String REGISTRATOR_IMAGE_NAME = "gliderlabs/registrator" | ||
public static final String REGISTRATOR_TAG_NAME = "v6" | ||
|
||
public RegistratorConfig() { | ||
imageName = REGISTRATOR_IMAGE_NAME | ||
imageTag = REGISTRATOR_TAG_NAME | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
minimesos/src/main/java/com/containersol/minimesos/cluster/Consul.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.containersol.minimesos.cluster; | ||
|
||
/** | ||
* Consul functionality | ||
*/ | ||
public interface Consul extends ClusterProcess { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
minimesos/src/main/java/com/containersol/minimesos/cluster/Registrator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.containersol.minimesos.cluster; | ||
|
||
/** | ||
* Consul functionality | ||
*/ | ||
public interface Registrator extends ClusterProcess { | ||
|
||
void setConsul(Consul consul); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
minimesos/src/main/java/com/containersol/minimesos/mesos/RegistratorContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.containersol.minimesos.mesos; | ||
|
||
import com.containersol.minimesos.cluster.Consul; | ||
import com.containersol.minimesos.cluster.MesosCluster; | ||
import com.containersol.minimesos.cluster.Registrator; | ||
import com.containersol.minimesos.config.ConsulConfig; | ||
import com.containersol.minimesos.config.RegistratorConfig; | ||
import com.containersol.minimesos.integrationtest.container.AbstractContainer; | ||
import com.containersol.minimesos.docker.DockerClientFactory; | ||
import com.github.dockerjava.api.command.CreateContainerCmd; | ||
import com.github.dockerjava.api.model.Bind; | ||
|
||
/** | ||
* Registrator automatically registers and deregisters services for any Docker container by inspecting containers as they come online. | ||
*/ | ||
public class RegistratorContainer extends AbstractContainer implements Registrator { | ||
|
||
private RegistratorConfig config; | ||
|
||
private Consul consul; | ||
|
||
public RegistratorContainer(MesosCluster cluster, String uuid, String containerId) { | ||
this(cluster, uuid, containerId, new RegistratorConfig()); | ||
} | ||
|
||
private RegistratorContainer(MesosCluster cluster, String uuid, String containerId, RegistratorConfig config) { | ||
super(cluster, uuid, containerId, config); | ||
this.config = config; | ||
} | ||
|
||
public RegistratorContainer(RegistratorConfig registrator) { | ||
super(registrator); | ||
this.config = registrator; | ||
} | ||
|
||
@Override | ||
public String getRole() { | ||
return "registrator"; | ||
} | ||
|
||
@Override | ||
protected CreateContainerCmd dockerCommand() { | ||
return DockerClientFactory.build().createContainerCmd(config.getImageName() + ":" + config.getImageTag()) | ||
.withNetworkMode("host") | ||
.withBinds(Bind.parse("/var/run/docker.sock:/tmp/docker.sock")) | ||
.withCmd("-internal", String.format("consul://%s:%d", consul.getIpAddress(), ConsulConfig.CONSUL_HTTP_PORT)) | ||
.withName(getName()); | ||
} | ||
|
||
public void setConsul(ConsulContainer consul) { | ||
this.consul = consul; | ||
} | ||
|
||
@Override | ||
public void setConsul(Consul consul) { | ||
this.consul = consul; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"args": [ | ||
"--zk={{MINIMESOS_ZOOKEEPER}}", | ||
"--consul=1", | ||
"--consul-ip={{MINIMESOS_CONSUL_IP}}" | ||
], | ||
"container": { | ||
"type": "DOCKER", | ||
"docker": { | ||
"network": "BRIDGE", | ||
"image": "containersol/mesos-consul:latest" | ||
} | ||
}, | ||
"id": "mesos-consul", | ||
"instances": 1, | ||
"cpus": 0.1, | ||
"mem": 256 | ||
} |
Oops, something went wrong.