pub struct Kubernetes { /* private fields */ }
Expand description
The main type for instantiating clients for managing kubernetes resources
Implementations§
Source§impl Kubernetes
impl Kubernetes
Sourcepub fn load_conf<P: AsRef<Path>>(path: P) -> Result<Kubernetes>
pub fn load_conf<P: AsRef<Path>>(path: P) -> Result<Kubernetes>
Initialize a Kubernetes client from a Kubernets config file
Incomplete: load_conf
was only implemented to meet
the needs of a single config, so it is currently hard-coded
to require a CA cert, a client cert, and skip hostname verification.
PRs for improving this are much appreciated.
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
Sourcepub fn load_conf_with_ctx<P: AsRef<Path>>(
path: P,
ctxname: &str,
) -> Result<Kubernetes>
pub fn load_conf_with_ctx<P: AsRef<Path>>( path: P, ctxname: &str, ) -> Result<Kubernetes>
Initialize a Kubernetes client from a Kubernets config file
Incomplete: load_conf
was only implemented to meet
the needs of a single config, so it is currently hard-coded
to require a CA cert, a client cert, and skip hostname verification.
PRs for improving this are much appreciated.
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
Sourcepub fn config_maps(&self) -> KubeClient<ConfigMap>
pub fn config_maps(&self) -> KubeClient<ConfigMap>
Get a kubernetes client for managing ConfigMaps
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
if kube.config_maps().exists("my-config-map")? {
println!("Found 'my-config-map'")
}
Sourcepub fn deployments(&self) -> KubeClient<Deployment>
pub fn deployments(&self) -> KubeClient<Deployment>
Get a kubernetes client for managing Deployments
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
if kube.deployments().exists("web-server")? {
println!("Found 'web-server' deployment")
}
Sourcepub fn network_policies(&self) -> KubeClient<NetworkPolicy>
pub fn network_policies(&self) -> KubeClient<NetworkPolicy>
Get a kubernetes client for managing NetworkPolicies
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
if kube.network_policies().exists("web-server")? {
println!("Found 'web-server' network policy")
}
Sourcepub fn nodes(&self) -> KubeClient<Node>
pub fn nodes(&self) -> KubeClient<Node>
Get a kubernetes client for managing Nodes
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
if kube.nodes().exists("node-123")? {
println!("Found 'node-123'")
}
Sourcepub fn pods(&self) -> KubeClient<Pod>
pub fn pods(&self) -> KubeClient<Pod>
Get a kubernetes client for managing Pods
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
if kube.pods().exists("web-server-abcdefgh12345678")? {
println!("Found 'web-server-abcdefgh12345678' pod")
}
Sourcepub fn secrets(&self) -> KubeClient<Secret>
pub fn secrets(&self) -> KubeClient<Secret>
Get a kubernetes client for managing Secrets
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
if kube.secrets().exists("my-secret")? {
println!("Found 'my-secret'")
}
Sourcepub fn services(&self) -> KubeClient<Service>
pub fn services(&self) -> KubeClient<Service>
Get a kubernetes client for managing Services
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
if kube.services().exists("web-server")? {
println!("Found 'web-server' service")
}
Sourcepub fn namespace(&self, namespace: &str) -> Kubernetes
pub fn namespace(&self, namespace: &str) -> Kubernetes
Get a kubernetes client that uses a specific namespace
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
let cluster_info = kube.namespace("kube-system")
.secrets()
.get("clusterinfo")?;
Sourcepub fn logs(&self) -> Kubernetes
pub fn logs(&self) -> Kubernetes
Get a kubernetes client that uses a specific namespace
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
let cluster_info = kube.namespace("kube-system")
.secrets()
.get("clusterinfo")?;
Sourcepub fn healthy(&self) -> Result<bool>
pub fn healthy(&self) -> Result<bool>
Check to see if the Kubernetes API is healthy
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
let is_healthy = kube.healthy()?;
Sourcepub fn apply<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn apply<P: AsRef<Path>>(&self, path: P) -> Result<()>
Applies a JSON or YAML resource file
This is similar to the kubectl apply
CLI commands.
This may be a single file or an entire directory. If the resource(s) specified already exists, this method will NOT replace the resource.
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
let is_healthy = kube.apply("web-server/deployment.yaml")?;
Sourcepub fn replace<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn replace<P: AsRef<Path>>(&self, path: P) -> Result<()>
Replaces a JSON or YAML resource file
This is similar to the kubectl replace
CLI commands.
This may be a single file or an entire directory. If the resource(s) specified already exists, this method will replace the resource.
§Examples
let kube = Kubernetes::load_conf("admin.conf")?;
let is_healthy = kube.replace("web-server/deployment.yaml")?;
Sourcepub fn create<R: Resource>(&self, resource: &R) -> Result<R>
pub fn create<R: Resource>(&self, resource: &R) -> Result<R>
Creates a resource from a typed resource defintion
This is similar to the kubectl create
CLI commands.
Note: most of the resource type defintions are incomplete Pull requests to fill missing fields/types are appreciated (especially if documented).
§Examples:
let kube = Kubernetes::load_conf("admin.conf")?;
let mut secret = Secret::new("web-server");
secret.insert("db_password", "abc123");
let response = kube.create(&secret)?;
Trait Implementations§
Source§impl Clone for Kubernetes
impl Clone for Kubernetes
Source§fn clone(&self) -> Kubernetes
fn clone(&self) -> Kubernetes
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for Kubernetes
impl !RefUnwindSafe for Kubernetes
impl Send for Kubernetes
impl Sync for Kubernetes
impl Unpin for Kubernetes
impl !UnwindSafe for Kubernetes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more