simpleautoscaler

package
v0.0.0-...-76698d7 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDownscaleWindow = "5m"
	DefaultUpscaleWindow   = "5m"
	DefaultFieldType       = autoscalev1alpha1.OtherResourceType
)

Variables

View Source
var (
	ErrNotFoundPolicyField     = errors.New("not found policy field")
	ErrInvalidPolicyField      = errors.New("invalid policy field")
	ErrNotFoundResource        = errors.New("not found resource")
	ErrNotFoundResourceField   = errors.New("not found resource field")
	ErrUpdateResourceField     = errors.New("update resource field for error value")
	ErrUpdateResourceFieldType = errors.New("update resource field for error type")
)

Functions

func IsNotFoundPolicyField

func IsNotFoundPolicyField(err error) bool

func SimpleAutoScalerMutating

func SimpleAutoScalerMutating(scaleObj *autoscalev1alpha1.SimpleAutoScaler)

func SimpleAutoScalerValidating

func SimpleAutoScalerValidating(scaleObj autoscalev1alpha1.SimpleAutoScaler) (err error)

Types

type AutoScalerController

type AutoScalerController interface {
	RunOnce()
}

type Handler

type Handler interface {
	GetResource(kind, apiVersion, name, namespace string) (r Resource, err error)
	UpdateResourceFieldValue(kind, apiVersion, name, namespace string, fieldValue map[string]string) (err error)
	ListResourceByLabels(kind, apiVersion, namespace string, lablemap map[string]string) (r Resource, err error)
}

type PolicyResult

type PolicyResult struct {
	Path            string
	ScaleFactor     float64
	MinAllowed      apiresource.Quantity
	MaxAllowed      apiresource.Quantity
	DownscaleWindow time.Duration
	UpscaleWindow   time.Duration
	Type            string
}

type PolicyResultMap

type PolicyResultMap map[string]PolicyResult

type Resource

type Resource struct {
	Obj     unstructured.Unstructured
	Objlist unstructured.UnstructuredList
	Json    string
}

use query

func (*Resource) Query

func (r *Resource) Query(path string) (value string, ok bool)

func (*Resource) ToObjectReference

func (r *Resource) ToObjectReference() (references []*autoscalingv1.CrossVersionObjectReference)

type ResourceManager

type ResourceManager struct {
	ResourceHandler Handler
}

resource reader for read value from simple autoscaler

func NewResourceManager

func NewResourceManager(kubeclient runtimeclient.Client) ResourceManager

func (*ResourceManager) GetScaleFactorValue

func (r *ResourceManager) GetScaleFactorValue(ctx context.Context,
	policy autoscalev1alpha1.ScaleResourcePolicy, namespace string) (value float64, err error)

query scale factor value though custom resources

func (*ResourceManager) ListResourceReference

func (*ResourceManager) ReadObjectByPath

func (r *ResourceManager) ReadObjectByPath(ctx context.Context,
	kind, apiVersion, name, namespace, path string) (value float64, err error)

func (*ResourceManager) UpdateScalerResources

func (r *ResourceManager) UpdateScalerResources(objReference autoscalingv1.CrossVersionObjectReference, namespace string, fieldValue map[string]string) (err error)

update scaler resource function

type SimpleAutoScalerController

type SimpleAutoScalerController struct {
	Manager ResourceManager
	// contains filtered or unexported fields
}

func NewSimpleAutoScalerController

func NewSimpleAutoScalerController() (ctrl *SimpleAutoScalerController, err error)

func (*SimpleAutoScalerController) GetPolicyResult

func (s *SimpleAutoScalerController) GetPolicyResult(scalerObj *autoscalev1alpha1.SimpleAutoScaler) (result PolicyResultMap, err error)

获取扩容策略结果

func (*SimpleAutoScalerController) GetTargetResource

get target resource 获取待扩容的目标资源

func (*SimpleAutoScalerController) RunOnce

func (s *SimpleAutoScalerController) RunOnce(ctx context.Context)

func (*SimpleAutoScalerController) UpdatePolicyResult

func (s *SimpleAutoScalerController) UpdatePolicyResult(scalerObj *autoscalev1alpha1.SimpleAutoScaler, result PolicyResultMap) (err error)

更新扩容策略结果

func (*SimpleAutoScalerController) UpdateSimpleAutoScalerStatus

func (s *SimpleAutoScalerController) UpdateSimpleAutoScalerStatus(ctx context.Context, scalerObj autoscalev1alpha1.SimpleAutoScaler)

真实执行更新 simpleautoscaler的 status

func (*SimpleAutoScalerController) UpdateTargetResourceByDesired

func (s *SimpleAutoScalerController) UpdateTargetResourceByDesired(ctx context.Context, scalerObj *autoscalev1alpha1.SimpleAutoScaler)

update target resource, use SimpleAutoScalerResources infomation to update target resource update the DesiredFieldValue to target resource field 根据期望值更新目标资源

type SyncSpecFieldToStauts

type SyncSpecFieldToStauts struct {
	Field string
}

type UnstructruedHandler

type UnstructruedHandler struct {
	Client runtimeclient.Client
	// contains filtered or unexported fields
}

func NewUnstructruedHandler

func NewUnstructruedHandler(ctx context.Context, kubeclient runtimeclient.Client) *UnstructruedHandler

func (*UnstructruedHandler) GetResource

func (t *UnstructruedHandler) GetResource(kind, apiVersion, name, namespace string) (r Resource, err error)

get unstructrue

func (*UnstructruedHandler) ListResourceByLabels

func (t *UnstructruedHandler) ListResourceByLabels(kind, apiVersion, namespace string, lablemap map[string]string) (r Resource, err error)

list unstructrue

func (*UnstructruedHandler) RawUpdateResourceFieldValue

func (t *UnstructruedHandler) RawUpdateResourceFieldValue(kind, apiVersion, name, namespace string, fieldValue map[string]string) (resource Resource, err error)

func (*UnstructruedHandler) UpdateResourceFieldValue

func (t *UnstructruedHandler) UpdateResourceFieldValue(kind, apiVersion, name, namespace string, fieldValue map[string]string) (err error)

update unstructrue field

Jump to

Keyboard shortcuts

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