Documentation ¶
Index ¶
- Constants
- Variables
- func IsNotFoundPolicyField(err error) bool
- func SimpleAutoScalerMutating(scaleObj *autoscalev1alpha1.SimpleAutoScaler)
- func SimpleAutoScalerValidating(scaleObj autoscalev1alpha1.SimpleAutoScaler) (err error)
- type AutoScalerController
- type Handler
- type PolicyResult
- type PolicyResultMap
- type Resource
- type ResourceManager
- func (r *ResourceManager) GetScaleFactorValue(ctx context.Context, policy autoscalev1alpha1.ScaleResourcePolicy, ...) (value float64, err error)
- func (r *ResourceManager) ListResourceReference(ctx context.Context, target *autoscalev1alpha1.ScaleTargetResourceReference, ...) (cvor []*autoscalingv1.CrossVersionObjectReference, err error)
- func (r *ResourceManager) ReadObjectByPath(ctx context.Context, kind, apiVersion, name, namespace, path string) (value float64, err error)
- func (r *ResourceManager) UpdateScalerResources(objReference autoscalingv1.CrossVersionObjectReference, namespace string, ...) (err error)
- type SimpleAutoScalerController
- func (s *SimpleAutoScalerController) GetPolicyResult(scalerObj *autoscalev1alpha1.SimpleAutoScaler) (result PolicyResultMap, err error)
- func (s *SimpleAutoScalerController) GetTargetResource(ctx context.Context, scalerObj *autoscalev1alpha1.SimpleAutoScaler) (targetResource []autoscalev1alpha1.SimpleAutoScalerResources, err error)
- func (s *SimpleAutoScalerController) RunOnce(ctx context.Context)
- func (s *SimpleAutoScalerController) UpdatePolicyResult(scalerObj *autoscalev1alpha1.SimpleAutoScaler, result PolicyResultMap) (err error)
- func (s *SimpleAutoScalerController) UpdateSimpleAutoScalerStatus(ctx context.Context, scalerObj autoscalev1alpha1.SimpleAutoScaler)
- func (s *SimpleAutoScalerController) UpdateTargetResourceByDesired(ctx context.Context, scalerObj *autoscalev1alpha1.SimpleAutoScaler)
- type SyncSpecFieldToStauts
- type UnstructruedHandler
- func (t *UnstructruedHandler) GetResource(kind, apiVersion, name, namespace string) (r Resource, err error)
- func (t *UnstructruedHandler) ListResourceByLabels(kind, apiVersion, namespace string, lablemap map[string]string) (r Resource, err error)
- func (t *UnstructruedHandler) RawUpdateResourceFieldValue(kind, apiVersion, name, namespace string, fieldValue map[string]string) (resource Resource, err error)
- func (t *UnstructruedHandler) UpdateResourceFieldValue(kind, apiVersion, name, namespace string, fieldValue map[string]string) (err error)
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 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 PolicyResultMap ¶
type PolicyResultMap map[string]PolicyResult
type Resource ¶
type Resource struct { Obj unstructured.Unstructured Objlist unstructured.UnstructuredList Json string }
use query
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 (r *ResourceManager) ListResourceReference(ctx context.Context, target *autoscalev1alpha1.ScaleTargetResourceReference, namespace string) (cvor []*autoscalingv1.CrossVersionObjectReference, err error)
func (*ResourceManager) ReadObjectByPath ¶
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 ¶
func (s *SimpleAutoScalerController) GetTargetResource(ctx context.Context, scalerObj *autoscalev1alpha1.SimpleAutoScaler) (targetResource []autoscalev1alpha1.SimpleAutoScalerResources, err error)
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 (*UnstructruedHandler) UpdateResourceFieldValue ¶
func (t *UnstructruedHandler) UpdateResourceFieldValue(kind, apiVersion, name, namespace string, fieldValue map[string]string) (err error)
update unstructrue field
Click to show internal directories.
Click to hide internal directories.