pub async fn start(&self, address: std::net::SocketAddr) -> Result<(), failure::Error> {
        self.provider.lock().await.init().await?;
        let client = APIClient::new(self.kubeconfig.clone());
        // Create the node. If it already exists, "adopt" the node definition
        create_node(&client, &self.provider.lock().await.arch()).await;

        // Start updating the node lease periodically
        let update_client = client.clone();
        let node_updater = tokio::task::spawn(async move {
            let sleep_interval = std::time::Duration::from_secs(10);
            loop {
                update_node(&update_client).await;
                tokio::time::delay_for(sleep_interval).await;
            }
        });

        // This informer listens for pod events.
        let provider = self.provider.clone();
        let config = self.kubeconfig.clone();

        let pod_informer = tokio::task::spawn(async move {
            // Create our informer and start listening.
            let informer = Informer::new(client, ListParams::default(), Resource::all::<Pod>());
            loop {
                let mut stream = informer.poll().await.expect("informer poll failed").boxed();
                while let Some(event) = stream.try_next().await.unwrap() {
                    match provider
                        .lock()
                        .await
                        .handle_event(event, config.clone())
                        .await
                    {
                        Ok(_) => debug!("Handled event successfully"),
                        Err(e) => error!("Error handling event: {}", e),
                    };
                }
            }
        });

        // Start the webserver
        start_webserver(self.provider.clone(), &address).await?;

        // FIXME: If any of these dies, we should crash the Kubelet and let it restart.
        node_updater.await.expect("node update thread crashed");
        pod_informer.await.expect("informer thread crashed");
        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, address: std::net::SocketAddr) -> Result<(), failure::Error> {
        self.provider.lock().await.init().await?;
        let client = APIClient::new(self.kubeconfig.clone());
        // Create the node. If it already exists, "adopt" the node definition
        create_node(&client, &self.provider.lock().await.arch()).await;
        // Start updating the node lease periodically
        let update_client = client.clone();
        let node_updater = tokio::task::spawn(async move {
            let sleep_interval = std::time::Duration::from_secs(10);
            loop {
                update_node(&update_client).await;
                tokio::time::delay_for(sleep_interval).await;
            }
        });
        // This informer listens for pod events.
        let provider = self.provider.clone();
        let config = self.kubeconfig.clone();
        let pod_informer = tokio::task::spawn(async move {
            // Create our informer and start listening.
            let informer = Informer::new(client, ListParams::default(), Resource::all::<Pod>());
            loop {
                let mut stream = informer.poll().await.expect("informer poll failed").boxed();
                while let Some(event) = stream.try_next().await.unwrap() {
                    match provider
                        .lock()
                        .await
                        .handle_event(event, config.clone())
                        .await
                    {
                        Ok(_) => debug!("Handled event successfully"),
                        Err(e) => error!("Error handling event: {}", e),
                    };
                }
            }
        });
        // Start the webserver
        start_webserver(self.provider.clone(), &address).await?;
        // FIXME: If any of these dies, we should crash the Kubelet and let it restart.
        node_updater.await.expect("node update thread crashed");
        pod_informer.await.expect("informer thread crashed");
        Ok(())
    }
pub async fn start ( & self , address : std :: net :: SocketAddr ) -> Result < ( ) , failure :: Error > { self . provider . lock ( ) . await . init ( ) . await ? ; let client = APIClient :: new ( self . kubeconfig . clone ( ) ) ; // Create the node. If it already exists, "adopt" the node definition create_node ( & client , & self . provider . lock ( ) . await . arch ( ) ) . await ; // Start updating the node lease periodically let update_client = client . clone ( ) ; let node_updater = tokio :: task :: spawn ( async move { let sleep_interval = std :: time :: Duration :: from_secs ( 10 ) ; loop { update_node ( & update_client ) . await ; tokio :: time :: delay_for ( sleep_interval ) . await ; } } ) ; // This informer listens for pod events. let provider = self . provider . clone ( ) ; let config = self . kubeconfig . clone ( ) ; let pod_informer = tokio :: task :: spawn ( async move { // Create our informer and start listening. let informer = Informer :: new ( client , ListParams :: default ( ) , Resource :: all :: < Pod > ( ) ) ; loop { let mut stream = informer . poll ( ) . await . expect ( " " ) . boxed ( ) ; while let Some ( event ) = stream . try_next ( ) . await . unwrap ( ) { match provider . lock ( ) . await . handle_event ( event , config . clone ( ) ) . await { Ok ( _ ) => debug ! ( " " ) , Err ( e ) => error ! ( " " e ) , } ; } } } ) ; // Start the webserver start_webserver ( self . provider . clone ( ) , & address ) . await ? ; // FIXME: If any of these dies, we should crash the Kubelet and let it restart. node_updater . await . expect ( " " ) ; pod_informer . await . expect ( " " ) ; Ok ( ( ) ) }
Begin answering requests for the Kubelet.
Begin answering requests for the Kubelet .
&self
address
std::net::SocketAddr
&self
address
std::net::SocketAddr