Skip to content

Commit

Permalink
read and print data in configmap
Browse files Browse the repository at this point in the history
  • Loading branch information
koushik-ms committed Oct 24, 2023
1 parent 0f60e45 commit bef8194
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions kata/kubeget/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
kube = { version = "0.86.0", features = ["runtime", "derive"] }
k8s-openapi = { version = "0.20.0", features = ["latest"] }
tokio = { version = "1.33.0", features = ["full"] }
anyhow = "1.0.75"
14 changes: 13 additions & 1 deletion kata/kubeget/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
fn main() {
// use k8s_openapi::api::core::v1::Pod;
use k8s_openapi::api::core::v1::ConfigMap;
use kube::{Client, Api};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
println!("Hello, world!");
let client = Client::try_default().await?;
let cm_api: Api<ConfigMap> = Api::namespaced(client, "kube-system");
let cm = cm_api.get("coredns").await?;
if let Some(data) = cm.data {
println!("Obtained Data: {:?}", data);
}
Ok(())
}

0 comments on commit bef8194

Please sign in to comment.