-
-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Api::namespaced should work with default namespace #209
Comments
This interplays with the planned api changes in #194.
Slightly harder to do |
Actually, only doing one of them is awkward for the let namespace = env::var("NAMESPACE").unwrap_or("default".into());
let resource = Resource::namespaced::<Pod>(&namespace);
let inf = Informer::new(client, ListParams::default(), resource); We should probably move Informers and Reflectors to use |
Stashed diff: diff --git kube/src/api/typed.rs kube/src/api/typed.rs
index 16d985e5..996479ea 100644
--- kube/src/api/typed.rs
+++ kube/src/api/typed.rs
@@ -53,6 +53,16 @@ where
phantom: PhantomData,
}
}
+
+ /// Namespaced resource within the configured default namespace
+ pub fn default_namespaced(client: Client) -> Self {
+ let api = Resource::namespaced::<K>(&client.default_ns);
+ Self {
+ api,
+ client,
+ phantom: PhantomData,
+ }
+ }
}
/// PUSH/PUT/POST/GET abstractions
diff --git kube/src/client/mod.rs kube/src/client/mod.rs
index 8738c0f5..280a535f 100644
--- kube/src/client/mod.rs
+++ kube/src/client/mod.rs
@@ -65,7 +65,7 @@ pub struct Status {
#[derive(Clone)]
pub struct Client {
cluster_url: reqwest::Url,
- default_ns: String,
+ pub(crate) default_ns: String,
inner: reqwest::Client,
}
|
released in 0.56 |
Currently the kube::Config picks up on the default namespace in two ways:
SERVICE_DEFAULT_NS
evar providedWhich can be passed onto the
kube::Client
so thatApi::namsepaced
andResource::namespaced
can omit this if they want a controller to run in the namespace they were deployed to.The text was updated successfully, but these errors were encountered: