Beispiel #1
0
    def _get_coordinator_endpoint(self):
        # Note that only support NodePort service type
        if is_minikube_cluster() and self._minikube_vm_driver:
            return self._get_minikube_service(self._namespace,
                                              self._coordinator_service_name)

        services = self._core_api.list_namespaced_service(self._namespace)
        for svc in services.items:
            if svc.metadata.name == self._coordinator_service_name:
                port = svc.spec.ports[0].node_port

                if svc.status.load_balancer.ingress is not None:
                    ingress = svc.status.load_balancer.ingress[0]
                    if ingress.hostname is not None:
                        host = ingress.hostname
                    else:
                        host = ingress.ip
                else:
                    selector = ""
                    for k, v in svc.spec.selector.items():
                        selector += k + "=" + v + ","
                    selector = selector[:-1]

                    # get pod
                    pods = self._core_api.list_namespaced_pod(
                        self._namespace, label_selector=selector)
                    host = pods.items[0].status.host_ip
                return "{}:{}".format(host, port)
        raise RuntimeError("Get coordinator endpoint failed.")
Beispiel #2
0
    def _get_coordinator_endpoint(self):
        if is_minikube_cluster() and self._minikube_vm_driver:
            return self._get_minikube_service(self._namespace,
                                              self._coordinator_service_name)

        # Always len(endpoints) >= 1
        endpoints = get_service_endpoints(
            api_client=self._api_client,
            namespace=self._namespace,
            name=self._coordinator_service_name,
            type=self._service_type,
        )

        return endpoints[0]
Beispiel #3
0
 def check_and_set_vineyard_rpc_endpoint(self, engine_config):
     if is_minikube_cluster() and self._minikube_vm_driver:
         engine_config[
             "vineyard_rpc_endpoint"] = self._get_minikube_service(
                 self._namespace, engine_config["vineyard_service_name"])