#config-file #kubernetes #kube #yaml

kube-conf

轻松获取用户本地的 Kubernetes 配置文件

2 个不稳定版本

0.2.0 2019年6月7日
0.1.0 2019年4月27日

#899 in 配置

Download history 9/week @ 2024-03-10 6/week @ 2024-03-24 42/week @ 2024-03-31 3/week @ 2024-04-07

每月 78 次下载

MIT 许可证

19KB
226

kube-conf

Crates.io Build Status

轻松获取本地的 Kubernetes 配置文件

文档


lib.rs:

欢迎使用 kube-conf 库。

这个库是一种方便的方法,可以获取本地用户的 Kubernetes 配置文件并读取其值。

示例

获取当前上下文

use kube_conf::Config;
let config = Config::load("tests/config.yml")?;
let current_context = config.get_current_context().unwrap();

assert_eq!("dev-frontend", current_context.name);

获取默认的 kubeconfig 文件

这通常意味着位于 $HOME/.kube/config

use kube_conf::Config;
let config = Config::load_default()?;
let current_context = config.current_context.unwrap();

assert_eq!("dev-frontend", current_context);

依赖项

~4.5–6.5MB
~127K SLoC