pub struct MetricsClient { /* private fields */ }Expand description
Kubernetes metrics client.
Implementations§
Source§impl MetricsClient
impl MetricsClient
Sourcepub async fn new() -> Result<Self, MetricsError>
pub async fn new() -> Result<Self, MetricsError>
Create a new metrics client using the default kubeconfig.
Sourcepub async fn with_context(context: &str) -> Result<Self, MetricsError>
pub async fn with_context(context: &str) -> Result<Self, MetricsError>
Create a new metrics client with a specific kubeconfig context.
Sourcepub async fn current_context() -> Result<String, MetricsError>
pub async fn current_context() -> Result<String, MetricsError>
Get the current context name.
Sourcepub async fn list_contexts() -> Result<Vec<String>, MetricsError>
pub async fn list_contexts() -> Result<Vec<String>, MetricsError>
List available contexts.
Sourcepub async fn get_pod_resources(
&self,
namespace: Option<&str>,
) -> Result<Vec<PodResources>, MetricsError>
pub async fn get_pod_resources( &self, namespace: Option<&str>, ) -> Result<Vec<PodResources>, MetricsError>
Get pod resource specifications from the cluster.
Sourcepub async fn get_pod_metrics(
&self,
namespace: Option<&str>,
) -> Result<Vec<PodMetrics>, MetricsError>
pub async fn get_pod_metrics( &self, namespace: Option<&str>, ) -> Result<Vec<PodMetrics>, MetricsError>
Get pod metrics from the metrics-server.
Note: This requires the metrics-server to be installed in the cluster. The metrics API is a custom resource, so we use a raw request.
Sourcepub async fn compare_usage(
&self,
namespace: Option<&str>,
) -> Result<Vec<ResourceComparison>, MetricsError>
pub async fn compare_usage( &self, namespace: Option<&str>, ) -> Result<Vec<ResourceComparison>, MetricsError>
Compare actual usage against requested resources.
Sourcepub async fn is_metrics_available(&self) -> bool
pub async fn is_metrics_available(&self) -> bool
Check if metrics-server is available.
Auto Trait Implementations§
impl Freeze for MetricsClient
impl !RefUnwindSafe for MetricsClient
impl Send for MetricsClient
impl Sync for MetricsClient
impl Unpin for MetricsClient
impl !UnwindSafe for MetricsClient
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.