quotas

package
v4.23.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2023 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInitalNamespaceQuotas

func AddInitalNamespaceQuotas(ns *corev1.Namespace)

AddInitalNamespaceQuotas will add the default quotas to the namespace annotations. It will only add them, if there are currently no such annotations in place.

Types

type QuotaChecker

type QuotaChecker struct {
	// contains filtered or unexported fields
}

QuotaChecker can check the given resources against the quotas set on an intance namespace

func NewQuotaChecker

func NewQuotaChecker(c client.Client, claimName, claimNamespace, instanceNamespace string, r Resources, gr schema.GroupResource, gk schema.GroupKind, checkNamespaceQuota bool) QuotaChecker

NewQuotaChecker creates a new quota checker. checkNamespaceQuota specifies whether or not the checker should also take the amount of existing namespaces into account, or not.

func (*QuotaChecker) CheckQuotas

func (q *QuotaChecker) CheckQuotas(ctx context.Context) *apierrors.StatusError

CheckQuotas runs the given quotas against a namespace. It also checks if the amount of namepsaces is within the quota as well.

type Resources

type Resources struct {
	CPURequests        resource.Quantity
	CPURequestsPath    *field.Path
	CPULimits          resource.Quantity
	CPULimitsPath      *field.Path
	MemoryRequests     resource.Quantity
	MemoryRequestsPath *field.Path
	MemoryLimits       resource.Quantity
	MemoryLimitsPath   *field.Path
	Disk               resource.Quantity
	DiskPath           *field.Path
}

Resources contains the Resources that the given instance will use. If the service has more than 1 replica then the values need to be adjusted.

func FetchPlansFromCluster

func FetchPlansFromCluster(ctx context.Context, c client.Client, name, plan string) (Resources, error)

FetchPlansFromCluster will fetch the plans from the current PLANS_NAMESPACE namespace and parse them into Resources. By default PLANS_NAMESPACE should be the same namespace where the controller pod is running.

func (*Resources) CheckResourcesAgainstQuotas

func (r *Resources) CheckResourcesAgainstQuotas(ctx context.Context, c client.Client, claimName, instanceNamespace string, gk schema.GroupKind) *apierrors.StatusError

CheckResourcesAgainstQuotas will check the given resources either against: The resources in the instanceNamespace, if it's found Or against the default quotas, if not found The second case is usually triggered if a new instance is created, as we don't have a namespace to check against. Once the namespace exists, the composition should ensure that the annotations are set.

func (*Resources) MultiplyBy

func (r *Resources) MultiplyBy(i int64)

MultiplyBy multiplies the resources by given integer. if given integer is less or equal to 0 it will not do any operation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL