[][src]Crate kubelet

A crate for building custom Kubernetes kubelets.

The crate provides the [Provider] trait for declaring a Kubelet backend as well as a the Kubelet type which takes a [Provider] and runs a Kubelet server.

Example

use kubelet::Kubelet;
use kubelet::config::Config;
use kubelet::pod::Pod;
use kubelet::provider::Provider;

// Create some type that will act as your provider
struct MyProvider;

// Implement the `Provider` trait for that type
#[async_trait::async_trait]
impl Provider for MyProvider {
   const ARCH: &'static str = "my-arch";

   async fn add(&self, pod: Pod) -> anyhow::Result<()> {
       todo!("Implement Provider::add")
    }

    // Implement the rest of the methods
}

async {
    // Instantiate your provider type
    let provider = MyProvider;

    // Load a kubernetes configuration
    let kubeconfig = kube::Config::infer().await.unwrap();
    // Get a configuration for the Kubelet
    let kubelet_config = Config::default();

    // Instantiate the Kubelet
    let kubelet = Kubelet::new(provider, kubeconfig, kubelet_config).await.unwrap();
    // Start the Kubelet and block on it
    kubelet.start().await.unwrap();
};

Modules

config

Configuration for a Kubelet

container

container is a collection of utilities surrounding the Kubernetes container API.

handle

A convenience handle type for providers

log

log contains convenient wrappers around fetching logs from the Kubernetes API.

node

node contains wrappers around the Kubernetes node API, containing ways to create and update nodes operating within the cluster.

pod

pod is a collection of utilities surrounding the Kubernetes pod API.

provider

Traits and types needed to create backend providers for a Kubelet

store

store contains logic around fetching and storing modules.

volume

A module for use in managing volumes in providers. Use of this module is not mandatory to create a Provider, but it does provide common implementation logic for supported volume providers.

Structs

Kubelet

A Kubelet server backed by a given Provider.

Functions

bootstrap

bootstrap the cluster with TLS certificates