From bef81948db09b6bd8b62d6558cd3688daa512cbb Mon Sep 17 00:00:00 2001 From: Meenakshisundaram Koushik Date: Tue, 24 Oct 2023 10:47:26 +0530 Subject: [PATCH] read and print data in configmap --- kata/kubeget/Cargo.toml | 4 ++++ kata/kubeget/src/main.rs | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/kata/kubeget/Cargo.toml b/kata/kubeget/Cargo.toml index 616fe9b..241705f 100644 --- a/kata/kubeget/Cargo.toml +++ b/kata/kubeget/Cargo.toml @@ -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" diff --git a/kata/kubeget/src/main.rs b/kata/kubeget/src/main.rs index e7a11a9..96811af 100644 --- a/kata/kubeget/src/main.rs +++ b/kata/kubeget/src/main.rs @@ -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 = Api::namespaced(client, "kube-system"); + let cm = cm_api.get("coredns").await?; + if let Some(data) = cm.data { + println!("Obtained Data: {:?}", data); + } + Ok(()) }