Skip to content
This repository has been archived by the owner on Jun 22, 2018. It is now read-only.

Commit

Permalink
Replaced Consul and Registrator with Mesos DNS.
Browse files Browse the repository at this point in the history
  • Loading branch information
frankscholten committed Feb 24, 2017
1 parent 6e28f9d commit 21f4672
Show file tree
Hide file tree
Showing 24 changed files with 115 additions and 227 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ setup:
deps:
docker pull containersol/mesos-agent:1.0.0-0.1.0
docker pull containersol/mesos-master:1.0.0-0.1.0
docker pull gliderlabs/registrator:v6
docker pull consul:0.7.1
docker pull mesosphere/mesos-dns:v0.6.0
docker pull mesosphere/marathon:v1.3.5
docker pull jplock/zookeeper:3.4.6
docker pull containersol/alpine3.3-java8-jre:v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public void testFileContent() throws IOException {
assertTrue("agent section is not found", fileContent.contains("agent {"));
assertTrue("agent resources section is not found", fileContent.contains("resources {"));
assertTrue("zookeeper section is not found", fileContent.contains("zookeeper {"));
assertTrue("consul section is not found", fileContent.contains("consul {"));
assertTrue("registrator section is not found", fileContent.contains("registrator {"));
assertTrue("mesosdns section is not found", fileContent.contains("mesosdns {"));
}

@Test(expected = MinimesosException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void testUpAndDestroy() {

assertTrue("Minimesos file at " + minimesosFile + " should exist", minimesosFile.exists());

assertEquals(6, cluster.getMemberProcesses().size());
assertEquals(5, cluster.getMemberProcesses().size());

cluster.destroy(new MesosClusterContainersFactory());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ minimesos {
}
}

consul {
imageName = "consul"
imageTag = "0.7.1"
}

marathon {
imageName = "mesosphere/marathon"
imageTag = "v1.3.5"
Expand All @@ -54,9 +49,9 @@ minimesos {
loggingLevel = "# INHERIT FROM CLUSTER"
}

registrator {
imageName = "gliderlabs/registrator"
imageTag = "v6"
mesosdns {
imageName = "xebia/mesos-dns"
imageTag = "0.0.5"
}

zookeeper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ minimesos {
}
}

consul {
imageName = "consul"
imageTag = "0.7.1"
}

marathon {
imageName = "mesosphere/marathon"
imageTag = "v1.3.5"
Expand All @@ -55,9 +50,9 @@ minimesos {
imageTag = "1.0.0-0.1.0"
}

registrator {
imageName = "gliderlabs/registrator"
imageTag = "v6"
mesosdns {
imageName = "xebia/mesos-dns"
imageTag = "0.0.5"
}

zookeeper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
import com.containersol.minimesos.config.AppConfig;
import com.containersol.minimesos.config.ClusterConfig;
import com.containersol.minimesos.config.ConfigParser;
import com.containersol.minimesos.config.ConsulConfig;
import com.containersol.minimesos.config.MarathonConfig;
import com.containersol.minimesos.config.MesosAgentConfig;
import com.containersol.minimesos.config.MesosMasterConfig;
import com.containersol.minimesos.config.RegistratorConfig;
import com.containersol.minimesos.config.MesosDNSConfig;
import com.containersol.minimesos.config.ZooKeeperConfig;

import org.slf4j.Logger;
Expand Down Expand Up @@ -85,8 +84,7 @@ public String getConfigFileContent() {
config.setMaster(new MesosMasterConfig(ClusterConfig.DEFAULT_MESOS_VERSION));
config.setZookeeper(new ZooKeeperConfig());
config.getAgents().add(new MesosAgentConfig(ClusterConfig.DEFAULT_MESOS_VERSION));
config.setConsul(new ConsulConfig());
config.setRegistrator(new RegistratorConfig());
config.setMesosdns(new MesosDNSConfig());

AppConfig weaveConfig = new AppConfig();
weaveConfig.setMarathonJson("https://raw.githubusercontent.com/ContainerSolutions/minimesos/master/opt/apps/weave-scope.json");
Expand Down
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ Scalar values are simple key-value strings.
| agent resources mem | Block | Describes memory resources |
| agent resources ports | Block | Describes network ports resources |

## Consul and registrator
By default, minimesos starts consul and registrator containers giving you ability to configure service discovery.
## Mesos DNS

Mesos DNS registers Mesos processes and frameworks in its DNS server

## Java API

Expand Down Expand Up @@ -228,7 +229,6 @@ export MINIMESOS_NETWORK_GATEWAY=172.17.0.1
export MINIMESOS_AGENT=http://172.17.0.5:5051; export MINIMESOS_AGENT_IP=172.17.0.5
export MINIMESOS_ZOOKEEPER=zk://172.17.0.3:2181/mesos; export MINIMESOS_ZOOKEEPER_IP=172.17.0.3
export MINIMESOS_MARATHON=http://172.17.0.6:8080; export MINIMESOS_MARATHON_IP=172.17.0.6
export MINIMESOS_CONSUL=http://172.17.0.7:8500; export MINIMESOS_CONSUL_IP=172.17.0.7
export MINIMESOS_MASTER=http://172.17.0.4:5050; export MINIMESOS_MASTER_IP=172.17.0.4
$ minimesos state | jq ".version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class ClusterConfig extends GroovyBlock {
List<MesosAgentConfig> agents = new ArrayList<>()
ZooKeeperConfig zookeeper = null
MarathonConfig marathon = null
ConsulConfig consul = null
RegistratorConfig registrator = null
MesosDNSConfig mesosdns = null

def master(@DelegatesTo(MesosMasterConfig) Closure cl) {
if (master != null) {
Expand Down Expand Up @@ -64,20 +63,12 @@ class ClusterConfig extends GroovyBlock {
delegateTo(marathon, cl)
}

def consul(@DelegatesTo(ConsulConfig) Closure cl) {
if (consul != null) {
throw new RuntimeException("Cannot have more than 1 Consul server")
def mesosdns(@DelegatesTo(MesosDNSConfig) Closure cl) {
if (mesosdns != null) {
throw new RuntimeException("Cannot have more than 1 mesosDNS")
}
consul = new ConsulConfig()
delegateTo(consul, cl)
}

def registrator(@DelegatesTo(RegistratorConfig) Closure cl) {
if (registrator != null) {
throw new RuntimeException("Cannot have more than 1 registrator")
}
registrator = new RegistratorConfig()
delegateTo(registrator, cl)
mesosdns = new MesosDNSConfig()
delegateTo(mesosdns, cl)
}

void setLoggingLevel(String loggingLevel) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.containersol.minimesos.config;

public class MesosDNSConfig extends ContainerConfigBlock implements ContainerConfig {

public static final String MESOS_DNS_IMAGE_NAME = "xebia/mesos-dns"
public static final String MESOS_DNS_TAG_NAME = "0.0.5"

public MesosDNSConfig() {
imageName = MESOS_DNS_IMAGE_NAME
imageTag = MESOS_DNS_TAG_NAME
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static List<ClusterProcess> getDistinctRoleProcesses(List<ClusterProcess>
}

for (Map.Entry<String, Integer> role : roles.entrySet() ) {
if (role.getValue() == 1) {
if (role.getValue() >= 1) {
Optional<ClusterProcess> process = processes.stream().filter(withRole(role.getKey())).findFirst();
distinct.add(process.get());
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ public static Predicate<ClusterProcess> zooKeeper() {
return process -> process instanceof ZooKeeper;
}

public static Predicate<ClusterProcess> consul() {
return process -> process instanceof Consul;
}

public static Predicate<ClusterProcess> mesosMaster() {
return process -> process instanceof MesosMaster;
}
Expand All @@ -31,5 +27,4 @@ public static Predicate<ClusterProcess> withRole(String role) {
return process -> role.equals(process.getRole());
}

public static Predicate<ClusterProcess> registrator() { return process -> process instanceof Registrator; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,6 @@ public Marathon getMarathon() {
return marathon.isPresent() ? marathon.get() : null;
}

public Consul getConsul() {
Optional<Consul> container = getOne(Filter.consul());
return container.isPresent() ? container.get() : null;
}

/**
* Optionally get one of a certain type of type T. Note, this cast will always work because we are filtering on that type.
* If it doesn't find that type, the optional is empty so the cast doesn't need to be performed.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.containersol.minimesos.cluster;

/**
* Mesos DNS
*/
public interface MesosDNS extends ClusterProcess {

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@

import com.containersol.minimesos.MinimesosException;
import com.containersol.minimesos.cluster.ClusterProcess;
import com.containersol.minimesos.cluster.Consul;
import com.containersol.minimesos.cluster.Filter;
import com.containersol.minimesos.cluster.Marathon;
import com.containersol.minimesos.cluster.MesosAgent;
import com.containersol.minimesos.cluster.MesosCluster;
import com.containersol.minimesos.cluster.MesosClusterFactory;
import com.containersol.minimesos.cluster.MesosMaster;
import com.containersol.minimesos.cluster.Registrator;
import com.containersol.minimesos.cluster.MesosDNS;
import com.containersol.minimesos.cluster.ZooKeeper;
import com.containersol.minimesos.config.ClusterConfig;
import com.containersol.minimesos.config.ConfigParser;
Expand Down Expand Up @@ -54,12 +53,8 @@ public Marathon createMarathon(MesosCluster mesosCluster, String uuid, String co
return new MarathonContainer(mesosCluster, uuid, containerId);
}

public Consul createConsul(MesosCluster mesosCluster, String uuid, String containerId) {
return new ConsulContainer(mesosCluster, uuid, containerId);
}

public Registrator createRegistrator(MesosCluster mesosCluster, String uuid, String containerId) {
return new RegistratorContainer(mesosCluster, uuid, containerId);
public MesosDNS createMesosDNS(MesosCluster mesosCluster, String uuid, String containerId) {
return new MesosDNSContainer(mesosCluster, uuid, containerId);
}

@Override
Expand Down Expand Up @@ -98,11 +93,8 @@ public void loadRunningCluster(MesosCluster cluster) {
case "marathon":
containers.add(createMarathon(cluster, uuid, containerId));
break;
case "consul":
containers.add(createConsul(cluster, uuid, containerId));
break;
case "registrator":
containers.add(createRegistrator(cluster, uuid, containerId));
case "mesosDNS":
containers.add(createMesosDNS(cluster, uuid, containerId));
break;
}
}
Expand Down Expand Up @@ -175,12 +167,8 @@ private static ClusterContainers createProcesses(ClusterConfig clusterConfig) {
clusterContainers.add(new MarathonContainer(clusterConfig.getMarathon()));
}

if (clusterConfig.getConsul() != null) {
clusterContainers.add(new ConsulContainer(clusterConfig.getConsul()));
}

if (clusterConfig.getRegistrator() != null) {
clusterContainers.add(new RegistratorContainer(clusterConfig.getRegistrator()));
if (clusterConfig.getMesosdns() != null) {
clusterContainers.add(new MesosDNSContainer(clusterConfig.getMesosdns()));
}

return clusterContainers;
Expand All @@ -200,10 +188,6 @@ private static void validateProcesses(ClusterContainers clusterContainers) {
if (!isPresent(clusterContainers, Filter.mesosAgent())) {
throw new MinimesosException("Cluster requires at least 1 Mesos Agent. Please add one in the minimesosFile.");
}

if (isPresent(clusterContainers, Filter.registrator()) && !isPresent(clusterContainers, Filter.consul())) {
throw new MinimesosException("Registrator requires a single Consul. Please add consul in the minimesosFile.");
}
}

private static void connectProcesses(ClusterContainers clusterContainers) {
Expand All @@ -222,12 +206,6 @@ private static void connectProcesses(ClusterContainers clusterContainers) {
MesosAgent agent = (MesosAgent) a;
agent.setZooKeeper(zookeeper);
});

if (clusterContainers.getOne(Filter.registrator()).isPresent()) {
Consul consul = (Consul) clusterContainers.getOne(Filter.consul()).get();
Registrator registrator = (Registrator) clusterContainers.getOne(Filter.registrator()).get();
registrator.setConsul(consul);
}
}

private static Boolean isPresent(ClusterContainers clusterContainers, Predicate<ClusterProcess> filter) {
Expand Down
Loading

0 comments on commit 21f4672

Please sign in to comment.