Documentation
¶
Overview ¶
Package calc provides function to calculate resource quotas for different k8s resources.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrResourceNotSupported is returned if a k8s resource is not supported by kuota-calc. ErrResourceNotSupported = errors.New("resource not supported") )
Functions ¶
func ConvertToRuntimeObjectFromYaml ¶
func ConvertToRuntimeObjectFromYaml(yamlData []byte, suppressWarningForUnregisteredKind bool) (object runtime.Object, kind, version *string, err error)
ConvertToRuntimeObjectFromYaml decodes a yaml document into a k8s object. If the kind is not found, it will display a warning.
Types ¶
type CalculationError ¶
type CalculationError struct { Version string Kind string // contains filtered or unexported fields }
CalculationError is an error implementation that includes a k8s Kind/Version.
func (CalculationError) Error ¶
func (cErr CalculationError) Error() string
func (CalculationError) Unwrap ¶
func (cErr CalculationError) Unwrap() error
Unwrap implements the errors.Unwrap interface.
type Details ¶
type Details struct { Version string Kind string Name string Strategy string Replicas int32 MaxReplicas int32 Hpa bool }
Details contains a few details of a k8s resource, which are needed to generate a detailed resource usage report.
type PodResources ¶
PodResources contain the sum of the resources required by the initContainer, the normal containers and the maximum the pod can require at any time for each resource quantity. In other words, max(Containers.MinCPU, InitContainers.MinCPU), max(Containers.MaxCPU, InitContainers.MaxCPU), etc.
type ResourceObject ¶
type ResourceObject struct { Object runtime.Object Kind string Version string LinkedObject runtime.Object }
ResourceObject is a struct that contains a k8s object, its kind and version and an optional linked object.
type ResourceUsage ¶
ResourceUsage summarizes the usage of compute resources for a k8s resource.
func ResourceQuotaFromYaml ¶
func ResourceQuotaFromYaml(resourceObject ResourceObject) (*ResourceUsage, error)
ResourceQuotaFromYaml decodes a single yaml document into a k8s object. Then performs a type assertion on the object and calculates the resource needs of it. Currently supported: * apps.openshift.io/v1 - DeploymentConfig * apps/v1 - Deployment * apps/v1 - StatefulSet * apps/v1 - DaemonSet * batch/v1 - CronJob * batch/v1 - Job * v1 - Pod
type Resources ¶
type Resources struct { CPUMin resource.Quantity CPUMax resource.Quantity MemoryMin resource.Quantity MemoryMax resource.Quantity }
Resources contains the limits and requests for cpu and memory that are typically used in kubernetes and openshift. Can be used to apply arithmetic operations equally on all quantities.
func ConvertToResources ¶
func ConvertToResources(req *v1.ResourceRequirements) Resources
ConvertToResources converts a kubernetes/openshift ResourceRequirements struct to a Resources struct
func Total ¶
func Total(maxRollout int, usage []*ResourceUsage) Resources
Total calculates the sum of all usages. maxRollout limits how many simultaneous rollouts are assumed. Negative maxRollout value -> unlimited rollouts.