1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//! A crate for building custom Kubernetes [kubelets](https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/).
//!
//! The crate provides the [`Provider`](crate::provider::Provider) trait for declaring a Kubelet
//! backend as well as a the [`Kubelet`] type which takes a [`Provider`](crate::provider::Provider)
//! and runs a Kubelet server.
//!
//! # Example
//! ```rust,no_run
//! use kubelet::Kubelet;
//! use kubelet::config::Config;
//! use kubelet::plugin_watcher::PluginRegistry;
//! use kubelet::pod::Pod;
//! use kubelet::provider::Provider;
//! use std::sync::Arc;
//! use tokio::sync::RwLock;
//! use kubelet::pod::state::prelude::*;
//! use kubelet::pod::state::Stub;
//!
//! // Create some type that will act as your provider
//! struct MyProvider;
//!
//! // Track shared provider-level state across pods.
//! struct ProviderState;
//! // Track pod state amongst pod state handlers.
//! struct PodState;
//!
//! #[async_trait::async_trait]
//! impl ObjectState for PodState {
//! type Manifest = Pod;
//! type Status = PodStatus;
//! type SharedState = ProviderState;
//! async fn async_drop(self, _provider_state: &mut ProviderState) {}
//! }
//!
//! // Implement the `Provider` trait for that type
//! #[async_trait::async_trait]
//! impl Provider for MyProvider {
//! const ARCH: &'static str = "my-arch";
//! type ProviderState = ProviderState;
//! type InitialState = Stub;
//! type TerminatedState = Stub;
//! type PodState = PodState;
//!
//! fn provider_state(&self) -> SharedState<ProviderState> {
//! Arc::new(RwLock::new(ProviderState {}))
//! }
//!
//! fn plugin_registry(&self) -> Option<Arc<PluginRegistry>> {
//! Some(Arc::new(Default::default()))
//! }
//!
//! async fn initialize_pod_state(&self, _pod: &Pod) -> anyhow::Result<Self::PodState> {
//! Ok(PodState)
//! }
//!
//! async fn logs(&self, namespace: String, pod: String, container: String, sender: kubelet::log::Sender) -> anyhow::Result<()> { todo!() }
//! }
//!
//! 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();
//! };
//! ```
pub
pub
pub
pub
pub
pub
pub use Kubelet;
pub use bootstrap;
extern crate krator;