webhooks

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RatioValidatiorDisableAnnotation = "validate-request-ratio.appuio.io/disable"

RatioValidatiorDisableAnnotation is the key for an annotion on a namespace to disable request ratio warnings

Functions

This section is empty.

Types

type Ratio

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

Ratio records resource requests and can calculate the current memory to CPU request ratio

func NewRatio

func NewRatio() *Ratio

NewRatio returns an initialized Ratio

func (Ratio) Below

func (r Ratio) Below(limit resource.Quantity) bool

Below returns if the memory to CPU ratio of the recorded objects is below the given limit. Always returns false if no CPU is requested.

func (Ratio) Ratio

func (r Ratio) Ratio() *resource.Quantity

Ratio returns the memory to CPU ratio of the recorded objects. Returns nil if there are no CPU requests.

func (*Ratio) RecordDeployment

func (r *Ratio) RecordDeployment(deps ...appsv1.Deployment) *Ratio

RecordDeployment collects all requests in the given deployment(s) and adds it to the ratio

func (*Ratio) RecordPod

func (r *Ratio) RecordPod(pods ...corev1.Pod) *Ratio

RecordPod collects all requests in the given Pod(s) and adds it to the ratio

func (*Ratio) RecordStatefulSet

func (r *Ratio) RecordStatefulSet(stss ...appsv1.StatefulSet) *Ratio

RecordStatefulSet collects all requests in the given StatefulSet(s) and adds it to the ratio

func (Ratio) String

func (r Ratio) String() string

String implements Stringer to print ratio

type RatioValidator

type RatioValidator struct {
	RatioLimit *resource.Quantity
	// contains filtered or unexported fields
}

RatioValidator checks for every action in a namespace whether the Memory to CPU ratio limit is exceeded and will return a warning if it is.

func (*RatioValidator) Handle

Handle handles the admission requests

func (*RatioValidator) InjectClient

func (v *RatioValidator) InjectClient(c client.Client) error

InjectClient injects a Kubernetes client

func (*RatioValidator) InjectDecoder

func (v *RatioValidator) InjectDecoder(d *admission.Decoder) error

InjectDecoder injects a Admission request decoder

Jump to

Keyboard shortcuts

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