Struct qube::clients::Kubernetes

source ·
pub struct Kubernetes { /* private fields */ }
Expand description

The main type for instantiating clients for managing kubernetes resources

Implementations§

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")?;

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")?;

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'")
}

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")
}

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")
}

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'")
}

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")
}

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'")
}

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")
}

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")?;

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")?;

Check to see if the Kubernetes API is healthy

Examples
let kube = Kubernetes::load_conf("admin.conf")?;
let is_healthy = kube.healthy()?;

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")?;

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")?;

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§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.