Struct qube::clients::Kubernetes
source · 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§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more