quota

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BasicStorage corev1.ResourceName = "basic.storageclass.storage.k8s.io/requests.storage"
	CPU          corev1.ResourceName = "cpu"
	Memory       corev1.ResourceName = "memory"
	Pods         corev1.ResourceName = "pods"
	GPU          corev1.ResourceName = "requests.nvidia.com/gpu"
)

Variables

View Source
var (
	Configmaps  = resource.NewQuantity(100, resource.DecimalSI)
	Builds      = resource.NewQuantity(100, resource.DecimalSI)
	Cronjobs    = resource.NewQuantity(100, resource.DecimalSI)
	Daemonsets  = resource.NewQuantity(100, resource.DecimalSI)
	Deployments = resource.NewQuantity(100, resource.DecimalSI)
	Replicasets = resource.NewQuantity(100, resource.DecimalSI)
	Routes      = resource.NewQuantity(100, resource.DecimalSI)
	Secrets     = resource.NewQuantity(100, resource.DecimalSI)

	ZeroDecimal = resource.NewQuantity(0, resource.DecimalSI)

	DefaultQuota = corev1.ResourceQuotaSpec{Hard: DefaultQuotaHard}

	DefaultQuotaHard = corev1.ResourceList{"configmaps": *Configmaps, "count/builds.build.openshift.io": *Builds, "count/cronjobs.batch": *Cronjobs, "count/daemonsets.apps": *Daemonsets,
		"count/deployments.apps": *Deployments, "count/jobs.batch": *Cronjobs, "count/replicasets.apps": *Replicasets, "count/routes.route.openshift.io": *Routes,
		"secrets": *Secrets, "count/deploymentconfigs.apps.openshift.io": *deploymentconfigs, "count/buildconfigs.build.openshift.io": *buildconfigs, "count/serviceaccounts": *serviceaccounts,
		"count/statefulsets.apps": *statefulsets, "count/templates.template.openshift.io": *templates, "openshift.io/imagestreams": *imagestreams}

	ZeroedQuota = corev1.ResourceQuotaSpec{
		Hard: corev1.ResourceList{BasicStorage: *ZeroDecimal, CPU: *ZeroDecimal, Memory: *ZeroDecimal, Pods: *ZeroDecimal, GPU: *ZeroDecimal},
	}
)
View Source
var (
	ContainerLimits = corev1.LimitRangeItem{
		Type:           "Container",
		Min:            minContainer,
		Default:        defaultLimit,
		DefaultRequest: defaultRequest,
	}

	PVCLimits = corev1.LimitRangeItem{
		Type: "PersistentVolumeClaim",
		Min:  minPVC,
	}

	Limits = []corev1.LimitRangeItem{ContainerLimits, PVCLimits}
)

Functions

func ClusterResourceQuota

func ClusterResourceQuota(sns *objectcontext.ObjectContext) (*objectcontext.ObjectContext, error)

ClusterResourceQuota returns a ClusterResourceQuota object.

func CreateDefaultSNSLimitRange

func CreateDefaultSNSLimitRange(snsObject *objectcontext.ObjectContext) error

CreateDefaultSNSLimitRange creates a limit range object with some default values that we would like to limit and are not set by the user.

func CreateDefaultSNSResourceQuota

func CreateDefaultSNSResourceQuota(snsObject *objectcontext.ObjectContext) error

CreateDefaultSNSResourceQuota creates a ResourceQuota object with some default values that we would like to limit and are not set by the user. This is only created in subnamespaces that have a ClusterResourceQuota.

func DoesSNSCRQExists

DoesSNSCRQExists returns true if a ClusterResourceQuota exists.

func DoesSNSRQExists

DoesSNSRQExists returns true if a ResourceQuota exists.

func DoesSubnamespaceObjectExist

func DoesSubnamespaceObjectExist(sns *objectcontext.ObjectContext) (bool, *objectcontext.ObjectContext, error)

DoesSubnamespaceObjectExist returns true if an object quota exists.

func EnsureSubnamespaceObject

func EnsureSubnamespaceObject(snsObject *objectcontext.ObjectContext, isRq bool) (ctrl.Result, error)

EnsureSubnamespaceObject ensures that a quota object exists for a subnamespace.

func GetCrqPointer

func GetCrqPointer(subns client.Object) string

GetCrqPointer gets a subnamespace and returns its crq-pointer. If it has a CRQ, which means it's a subnamesapce or an upper-rp, it returns its name. If it doesn't, it returns the upper resourcepool's name.

func GetQuotaObjectSpec

func GetQuotaObjectSpec(QuotaObject client.Object) corev1.ResourceQuotaSpec

GetQuotaObjectSpec returns the quota of a quota object.

func GetQuotaObjectsListResources

func GetQuotaObjectsListResources(quotaObjs []*objectcontext.ObjectContext) corev1.ResourceList

GetQuotaObjectsListResources returns a ResourceList with all the resources of the given objects summed up.

func GetQuotaUsed

func GetQuotaUsed(QuotaObject client.Object) corev1.ResourceList

GetQuotaUsed returns the used value from the status of a quota object (RQ or CRQ).

func IsDefault

func IsDefault(QuotaObject client.Object) bool

IsDefault returns whether a quota object is default.

func IsRQ

func IsRQ(sns *objectcontext.ObjectContext, offset int) (bool, error)

IsRQ returns true if the depth of the subnamespace is less or equal the pre-set rqDepth AND if the subnamespace is not a ResourcePool.

func IsZeroed

func IsZeroed(QuotaObject client.Object) bool

IsZeroed returns whether a quota object is zeroed.

func NamespaceObject

NamespaceObject returns the quota object of a namespace.

func ResourceListEqual

func ResourceListEqual(resourceListA, resourceListB corev1.ResourceList) bool

ResourceListEqual gets two ResourceLists and returns whether their specs are equal.

func ResourceQuota

ResourceQuota returns a ResourceQuota object.

func ResourceQuotaSpecEqual

func ResourceQuotaSpecEqual(resourceQuotaSpecA, resourceQuotaSpecB corev1.ResourceQuotaSpec) bool

ResourceQuotaSpecEqual gets two ResourceQuotaSpecs and returns whether their specs are equal.

func RootNSObject

RootNSObject returns the quota object of a root namespace.

func RootNSObjectFromName

func RootNSObjectFromName(obj *objectcontext.ObjectContext, rootNSName string) (*objectcontext.ObjectContext, error)

RootNSObjectFromName returns the quota object of a root namespace.

func SubnamespaceChildrenObjects

func SubnamespaceChildrenObjects(sns *objectcontext.ObjectContext) []*objectcontext.ObjectContext

SubnamespaceChildrenObjects returns the quota objects of all the children of a subnamespace.

func SubnamespaceObject

func SubnamespaceObject(sns *objectcontext.ObjectContext) (*objectcontext.ObjectContext, error)

SubnamespaceObject returns the quota object of a subnamesapce.

func SubnamespaceObjectFromAnnotation

func SubnamespaceObjectFromAnnotation(sns *objectcontext.ObjectContext) (*objectcontext.ObjectContext, error)

SubnamespaceObjectFromAnnotation returns the quota object of a subnamesapce using annotations.

func SubnamespaceParentObject

func SubnamespaceParentObject(sns *objectcontext.ObjectContext) (*objectcontext.ObjectContext, error)

SubnamespaceParentObject returns the quota object of a subnamespace. The quota object can be either a ResourceQuota object or a ClusterResourceQuota object depending on the depth in the hierarchy of the SNS.

func SubnamespaceSiblingObjects

func SubnamespaceSiblingObjects(sns *objectcontext.ObjectContext) []*objectcontext.ObjectContext

SubnamespaceSiblingObjects returns a slice of the quota objects of all the siblings of a subnamespace.

func SubnamespaceSpec

func SubnamespaceSpec(sns client.Object) corev1.ResourceQuotaSpec

SubnamespaceSpec returns the ResourceQuotaSpec of a subnamespace.

func UpdateObject

func UpdateObject(quotaObject *objectcontext.ObjectContext, resources corev1.ResourceQuotaSpec, isRq bool) error

UpdateObject updates the spec of the quotaObject to be same as the given resources.

Types

This section is empty.

Jump to

Keyboard shortcuts

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