Share via


KubernetesResourceQuotaServiceCollectionExtensions.AddKubernetesResourceMonitoring Method

Definition

Configures and adds an Kubernetes resource monitoring components to a service collection altogether with necessary basic resource monitoring components.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddKubernetesResourceMonitoring(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string? environmentVariablePrefix = default);
static member AddKubernetesResourceMonitoring : Microsoft.Extensions.DependencyInjection.IServiceCollection * string -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddKubernetesResourceMonitoring (services As IServiceCollection, Optional environmentVariablePrefix As String = Nothing) As IServiceCollection

Parameters

services
IServiceCollection

The dependency injection container to add the Kubernetes resource monitoring to.

environmentVariablePrefix
String

Optional value of prefix used to read environment variables in the container.

Returns

The value of services.

Remarks

If you have configured your Kubernetes container with Downward API to add environment variable MYCLUSTER_LIMITS_CPU with CPU limits, then you should pass MYCLUSTER_ to environmentVariablePrefix parameter. Environment variables will be read during DI Container resolution.

Important: Do not call AddResourceMonitoring(IServiceCollection) if you are using this method, as it already includes all necessary resource monitoring components and registers a Kubernetes-specific ResourceQuotaProvider implementation. Calling both methods may result in conflicting service registrations.

Applies to