def run_peloton_hostmgr(config, enable_k8s=False):
    scarce_resource = ",".join(config["scarce_resource_types"])
    slack_resource = ",".join(config["slack_resource_types"])
    mounts = []
    env = {
        "SCARCE_RESOURCE_TYPES": scarce_resource,
        "SLACK_RESOURCE_TYPES": slack_resource,
    }
    if enable_k8s:
        k8s = kind.Kind(PELOTON_K8S_NAME)
        kubeconfig_dir = os.path.dirname(k8s.get_kubeconfig())
        mounts = [kubeconfig_dir + ":/.kube"]
        env.update({
            "ENABLE_K8S": True,
            "KUBECONFIG": "/.kube/kind-config-peloton-k8s",
        })

    for i in range(0, config["peloton_hostmgr_instance_count"]):
        # to not cause port conflicts among apps, increase port
        # by 10 for each instance
        ports = [port + i * 10 for port in config["peloton_hostmgr_ports"]]
        name = config["peloton_hostmgr_container"] + repr(i)
        utils.remove_existing_container(name)
        start_and_wait(
            "hostmgr",
            name,
            ports,
            config,
            extra_env=env,
            mounts=mounts,
        )
Example #2
0
def teardown_k8s():
    k8s = kind.Kind(PELOTON_K8S_NAME)
    try:
        return k8s.teardown()
    except OSError as e:
        if e.errno == 2:
            print_utils.warn("kubernetes was not running")
            return True
        else:
            raise
Example #3
0
    def __init__(self, config, disable_mesos=False,
                 enable_k8s=False, enable_peloton=False,
                 use_host_pool=False,
                 disabled_applications={}, zk_url=None):
        self.config = config
        self.disable_mesos = disable_mesos
        self.enable_k8s = enable_k8s
        self.enable_peloton = enable_peloton
        self.disabled_applications = disabled_applications
        self.zk_url = zk_url
        self.config['use_host_pool'] = use_host_pool

        self.k8s = kind.Kind(config["k8s_cluster_name"])
        self._peloton_client = None
        self._namespace = ""  # Used for isolating miniclusters from each other
        self.cli = Client(base_url="unix://var/run/docker.sock",
                          namespace=self._namespace)
        self._create_peloton_ports()
        self._create_mesos_ports()

        global default_cluster
        default_cluster = self

        # Defines the order in which the apps are started
        # NB: HOST_MANAGER is tied to database migrations so should
        # be started first
        # TODO: Start all apps at the same time.
        self.APP_START_ORDER = OrderedDict(
            [
                (MOCK_CQOS, self.run_peloton_mockcqos),
                (HOST_MANAGER, self.run_peloton_hostmgr),
                (RESOURCE_MANAGER, self.run_peloton_resmgr),
                (PLACEMENT_ENGINE, self.run_peloton_placement),
                (JOB_MANAGER, self.run_peloton_jobmgr),
                (ARCHIVER, self.run_peloton_archiver),
                (AURORABRIDGE, self.run_peloton_aurorabridge),
                (APISERVER, self.run_peloton_apiserver),
            ]
        )
Example #4
0
def run_k8s():
    k8s = kind.Kind(PELOTON_K8S_NAME)
    k8s.teardown()
    k8s.create()
Example #5
0
def teardown_k8s():
    k8s = kind.Kind(PELOTON_K8S_NAME)
    return k8s.teardown()
def run_k8s():
    print_utils.okgreen("starting k8s cluster")
    k8s = kind.Kind(PELOTON_K8S_NAME)
    k8s.teardown()
    k8s.create()
    print_utils.okgreen("started k8s cluster")