-
-
Notifications
You must be signed in to change notification settings - Fork 322
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
1 changed file
with
28 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#[macro_use] extern crate log; | ||
use futures::{StreamExt, TryStreamExt}; | ||
use k8s_openapi::api::core::v1::ConfigMap; | ||
use kube::{ | ||
api::{Api, ListParams}, | ||
runtime::Informer, | ||
Client, | ||
}; | ||
|
||
/// Example way to read secrets | ||
#[tokio::main] | ||
async fn main() -> anyhow::Result<()> { | ||
std::env::set_var("RUST_LOG", "info,kube=debug"); | ||
env_logger::init(); | ||
let client = Client::try_default().await?; | ||
let namespace = std::env::var("NAMESPACE").unwrap_or("default".into()); | ||
|
||
let cms: Api<ConfigMap> = Api::namespaced(client, &namespace); | ||
let lp = ListParams::default().timeout(10); // short watch timeout in this example | ||
let inf = Informer::new(cms).params(lp); | ||
|
||
loop { | ||
let mut stream = inf.poll().await?.boxed(); | ||
while let Some(event) = stream.try_next().await? { | ||
info!("Got: {:?}", event); | ||
} | ||
} | ||
} |