pub async fn start(&self) -> anyhow::Result<()> {
        let client = kube::Client::new(self.kube_config.clone());

        // Create the node. If it already exists, this will exit
        node::create(&client, &self.config, self.provider.clone()).await;

        // Flag to indicate graceful shutdown has started.
        let signal = Arc::new(AtomicBool::new(false));
        let signal_task = start_signal_task(Arc::clone(&signal)).fuse();

        // Start the webserver
        let webserver = start_webserver(self.provider.clone(), &self.config.server_config).fuse();

        // Start updating the node lease and status periodically
        let node_updater = start_node_updater(client.clone(), self.config.node_name.clone()).fuse();

        // If any of these tasks fail, we can initiate graceful shutdown.
        let services = Box::pin(async {
            tokio::select! {
                res = signal_task => if let Err(e) = res {
                    error!("Signal task completed with error {:?}", &e);
                },
                res = webserver => error!("Webserver task completed with result {:?}", &res),
                res = node_updater => if let Err(e) = res {
                    error!("Node updater task completed with error {:?}", &e);
                }
            };
            // Use relaxed ordering because we just need other tasks to eventually catch the signal.
            signal.store(true, Ordering::Relaxed);
            Ok::<(), anyhow::Error>(())
        });

        // Periodically checks for shutdown signal and cleans up resources gracefully if caught.
        let signal_handler = start_signal_handler(
            Arc::clone(&signal),
            client.clone(),
            self.config.node_name.clone(),
        )
        .fuse();

        // Create a queue that locks on events per pod
        let queue = Queue::new(self.provider.clone(), client.clone());
        let pod_informer = start_pod_informer::<P>(
            client.clone(),
            self.config.node_name.clone(),
            queue,
            Arc::clone(&signal),
        )
        .fuse();

        // These must all be running for graceful shutdown. An error here exits ungracefully.
        let core = Box::pin(async {
            tokio::select! {
                res = signal_handler => res.map_err(|e| {
                    error!("Signal handler task joined with error {:?}", &e);
                    e
                }),
                _ = pod_informer => {
                    warn!("Pod informer has completed");
                    Ok(())
                }
            }
        });

        // Services will not return an error, so this will wait for both to return, or core to
        // return an error. Services will return if signal is set because pod_informer will drop
        // error_sender and error_handler will exit.
        tokio::try_join!(core, services)?;
        Ok(())
    }
/// Begin answering requests for the Kubelet.
///
/// This will listen on the given address, and will also begin watching for Pod
/// events, which it will handle.
Begin answering requests for the Kubelet.
This will listen on the given address, and will also begin watching for Pod
events, which it will handle.
Begin answering requests for the Kubelet . This will listen on the given address and will also begin watching for Pod events which it will handle .
pub async fn start(&self) -> anyhow::Result<()> {
        let client = kube::Client::new(self.kube_config.clone());
        // Create the node. If it already exists, this will exit
        node::create(&client, &self.config, self.provider.clone()).await;
        // Flag to indicate graceful shutdown has started.
        let signal = Arc::new(AtomicBool::new(false));
        let signal_task = start_signal_task(Arc::clone(&signal)).fuse();
        // Start the webserver
        let webserver = start_webserver(self.provider.clone(), &self.config.server_config).fuse();
        // Start updating the node lease and status periodically
        let node_updater = start_node_updater(client.clone(), self.config.node_name.clone()).fuse();
        // If any of these tasks fail, we can initiate graceful shutdown.
        let services = Box::pin(async {
            tokio::select! {
                res = signal_task => if let Err(e) = res {
                    error!("Signal task completed with error {:?}", &e);
                },
                res = webserver => error!("Webserver task completed with result {:?}", &res),
                res = node_updater => if let Err(e) = res {
                    error!("Node updater task completed with error {:?}", &e);
                }
            };
            // Use relaxed ordering because we just need other tasks to eventually catch the signal.
            signal.store(true, Ordering::Relaxed);
            Ok::<(), anyhow::Error>(())
        });
        // Periodically checks for shutdown signal and cleans up resources gracefully if caught.
        let signal_handler = start_signal_handler(
            Arc::clone(&signal),
            client.clone(),
            self.config.node_name.clone(),
        )
        .fuse();
        // Create a queue that locks on events per pod
        let queue = Queue::new(self.provider.clone(), client.clone());
        let pod_informer = start_pod_informer::<P>(
            client.clone(),
            self.config.node_name.clone(),
            queue,
            Arc::clone(&signal),
        )
        .fuse();
        // These must all be running for graceful shutdown. An error here exits ungracefully.
        let core = Box::pin(async {
            tokio::select! {
                res = signal_handler => res.map_err(|e| {
                    error!("Signal handler task joined with error {:?}", &e);
                    e
                }),
                _ = pod_informer => {
                    warn!("Pod informer has completed");
                    Ok(())
                }
            }
        });
        // Services will not return an error, so this will wait for both to return, or core to
        // return an error. Services will return if signal is set because pod_informer will drop
        // error_sender and error_handler will exit.
        tokio::try_join!(core, services)?;
        Ok(())
    }
pub async fn start ( & self ) -> anyhow :: Result < ( ) > { let client = kube :: Client :: new ( self . kube_config . clone ( ) ) ; // Create the node. If it already exists, this will exit node :: create ( & client , & self . config , self . provider . clone ( ) ) . await ; // Flag to indicate graceful shutdown has started. let signal = Arc :: new ( AtomicBool :: new ( false ) ) ; let signal_task = start_signal_task ( Arc :: clone ( & signal ) ) . fuse ( ) ; // Start the webserver let webserver = start_webserver ( self . provider . clone ( ) , & self . config . server_config ) . fuse ( ) ; // Start updating the node lease and status periodically let node_updater = start_node_updater ( client . clone ( ) , self . config . node_name . clone ( ) ) . fuse ( ) ; // If any of these tasks fail, we can initiate graceful shutdown. let services = Box :: pin ( async { tokio :: select ! { res signal_task if let Err ( e ) res { error ( " " e ) } res webserver error ( " " res ) res node_updater if let Err ( e ) res { error ( " " e ) } } ; // Use relaxed ordering because we just need other tasks to eventually catch the signal. signal . store ( true , Ordering :: Relaxed ) ; Ok :: < ( ) , anyhow :: Error > ( ( ) ) } ) ; // Periodically checks for shutdown signal and cleans up resources gracefully if caught. let signal_handler = start_signal_handler ( Arc :: clone ( & signal ) , client . clone ( ) , self . config . node_name . clone ( ) , ) . fuse ( ) ; // Create a queue that locks on events per pod let queue = Queue :: new ( self . provider . clone ( ) , client . clone ( ) ) ; let pod_informer = start_pod_informer :: < P > ( client . clone ( ) , self . config . node_name . clone ( ) , queue , Arc :: clone ( & signal ) , ) . fuse ( ) ; // These must all be running for graceful shutdown. An error here exits ungracefully. let core = Box :: pin ( async { tokio :: select ! { res signal_handler res map_err ( e { error ( " " e ) e } ) pod_informer { warn ( " " ) Ok ( ( ) ) } } } ) ; // Services will not return an error, so this will wait for both to return, or core to // return an error. Services will return if signal is set because pod_informer will drop // error_sender and error_handler will exit. tokio :: try_join ! ( core services ) ? ; Ok ( ( ) ) }
Begin answering requests for the Kubelet.
Begin answering requests for the Kubelet .
&self
&self