Esempio n. 1
0
    def __init__(self):
        # NOTE(mdulko): Default shutdown timeout is 60 seconds and K8s won't
        #               wait more by default anyway.
        super(CNIDaemonServiceManager, self).__init__()
        # TODO(dulek): Use cotyledon.oslo_config_glue to support conf reload.

        # TODO(vikasc): Should be done using dynamically loadable OVO types
        #               plugin.
        objects.register_locally_defined_vifs()

        os_vif.initialize()
        clients.setup_kubernetes_client()
        if CONF.sriov.enable_pod_resource_service:
            clients.setup_pod_resources_client()

        self.manager = multiprocessing.Manager()
        registry = self.manager.dict()  # For Watcher->Server communication.
        healthy = multiprocessing.Value(c_bool, True)
        self.add(CNIDaemonWatcherService,
                 workers=1,
                 args=(
                     registry,
                     healthy,
                 ))
        self._server_service = self.add(CNIDaemonServerService,
                                        workers=1,
                                        args=(registry, healthy))
        self.add(CNIDaemonHealthServerService, workers=1, args=(healthy, ))
        self.register_hooks(on_terminate=self.terminate)
Esempio n. 2
0
    def __init__(self):
        super(CNIDaemonServiceManager, self).__init__()
        # TODO(dulek): Use cotyledon.oslo_config_glue to support conf reload.

        # TODO(vikasc): Should be done using dynamically loadable OVO types
        #               plugin.
        objects.register_locally_defined_vifs()

        os_vif.initialize()
        clients.setup_kubernetes_client()

        self.manager = multiprocessing.Manager()
        registry = self.manager.dict()  # For Watcher->Server communication.
        healthy = multiprocessing.Value(c_bool, True)
        self.add(CNIDaemonWatcherService,
                 workers=1,
                 args=(
                     registry,
                     healthy,
                 ))
        self.add(CNIDaemonServerService, workers=1, args=(
            registry,
            healthy,
        ))
        self.add(CNIDaemonHealthServerService, workers=1, args=(healthy, ))
        self.register_hooks(on_terminate=self.terminate)
Esempio n. 3
0
 def _setup(self, params):
     clients.setup_kubernetes_client()
     self._pipeline = h_cni.CNIPipeline()
     self._watcher = k_watcher.Watcher(self._pipeline)
     self._watcher.add(
         "%(base)s/namespaces/%(namespace)s/pods"
         "?fieldSelector=metadata.name=%(pod)s" % {
             'base': k_const.K8S_API_BASE,
             'namespace': params.args.K8S_POD_NAMESPACE,
             'pod': params.args.K8S_POD_NAME})
Esempio n. 4
0
    def __init__(self):
        # NOTE(mdulko): Default shutdown timeout is 60 seconds and K8s won't
        #               wait more by default anyway.
        super(CNIDaemonServiceManager, self).__init__()
        self._server_service = None
        # TODO(dulek): Use cotyledon.oslo_config_glue to support conf reload.

        # TODO(vikasc): Should be done using dynamically loadable OVO types
        #               plugin.
        objects.register_locally_defined_vifs()

        os_vif.initialize()
        clients.setup_kubernetes_client()
        if CONF.sriov.enable_pod_resource_service:
            clients.setup_pod_resources_client()

        self.manager = multiprocessing.Manager()
        registry = self.manager.dict()  # For Watcher->Server communication.
        healthy = multiprocessing.Value(c_bool, True)
        metrics = self.manager.Queue()
        self.add(watcher_service.KuryrPortWatcherService,
                 workers=1,
                 args=(
                     registry,
                     healthy,
                 ))
        self.add(watcher_service.PodWatcherService,
                 workers=1,
                 args=(
                     registry,
                     healthy,
                 ))
        self._server_service = self.add(CNIDaemonServerService,
                                        workers=1,
                                        args=(
                                            registry,
                                            healthy,
                                            metrics,
                                        ))
        self.add(CNIDaemonHealthServerService, workers=1, args=(healthy, ))
        self.add(CNIDaemonExporterService, workers=1, args=(metrics, ))

        def shutdown_hook(service_id, worker_id, exit_code):
            LOG.critical(f'Child Service {service_id} had exited with code '
                         f'{exit_code}, stopping kuryr-daemon')
            self.shutdown()

        self.register_hooks(on_terminate=self.terminate,
                            on_dead_worker=shutdown_hook)
Esempio n. 5
0
    def _setup(self, params):
        args = ['--config-file', params.config.kuryr_conf]

        try:
            if params.config.debug:
                args.append('-d')
        except AttributeError:
            pass

        config.init(args)
        config.setup_logging()
        os_vif.initialize()
        clients.setup_kubernetes_client()
        self._pipeline = h_cni.CNIPipeline()
        self._watcher = k_watcher.Watcher(self._pipeline)
        self._watcher.add(
            "%(base)s/namespaces/%(namespace)s/pods"
            "?fieldSelector=metadata.name=%(pod)s" % {
                'base': k_const.K8S_API_BASE,
                'namespace': params.args.K8S_POD_NAMESPACE,
                'pod': params.args.K8S_POD_NAME
            })
Esempio n. 6
0
 def __init__(self):
     self.check_methods = {
         'Pod annotations': self._check_annotations,  # Stein
     }
     clients.setup_kubernetes_client()
     self.k8s = clients.get_kubernetes_client()