-
-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
450 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// This example shows how to use kube with dynamically known resource kinds. | ||
|
||
use color_eyre::Result; | ||
use futures::prelude::*; | ||
use kube::{ | ||
api::{DynamicObject, GroupVersionKind, ListParams, Meta}, | ||
Api, Client, | ||
}; | ||
use kube_runtime::{utils::try_flatten_applied, watcher}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
std::env::set_var("RUST_LOG", "info,kube=debug"); | ||
env_logger::init(); | ||
|
||
// alternatively, you can: | ||
// 1) take them CLI arguments | ||
// 2) use dynamic discovery apis on kube::Client and e.g. watch all | ||
// resources in cluster. | ||
let group = std::env::var("GROUP").expect("GROUP not set"); | ||
let group = group.trim(); | ||
let version = std::env::var("VERSION").expect("VERSION not set"); | ||
let version = version.trim(); | ||
let kind = std::env::var("KIND").expect("KIND not set"); | ||
let kind = kind.trim(); | ||
|
||
let gvk = GroupVersionKind::from_dynamic_gvk(group, version, kind); | ||
|
||
let client = Client::try_default().await?; | ||
let api = Api::<DynamicObject>::all_with(client, &gvk); | ||
let watcher = watcher(api, ListParams::default()); | ||
try_flatten_applied(watcher) | ||
.try_for_each(|p| async move { | ||
log::info!("Applied: {}", Meta::name(&p)); | ||
Ok(()) | ||
}) | ||
.await?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.