Documentation ¶
Index ¶
- Variables
- func RegisterNodeMetaCheckExtender(filter FilterFn, plugins ...NodeMetaCheckPlugin)
- func RegisterNodePreUpdateExtender(filter FilterFn, plugins ...NodePreUpdatePlugin)
- func RegisterNodePrepareExtender(filter FilterFn, plugins ...NodePreparePlugin)
- func RegisterNodeStatusCheckExtender(filter FilterFn, plugins ...NodeStatusCheckPlugin)
- func RegisterResourceCalculateExtender(filter FilterFn, plugins ...ResourceCalculatePlugin)
- func RegisterSetupExtender(filter FilterFn, plugins ...SetupPlugin)
- func RunNodeMetaCheckExtenders(strategy *configuration.ColocationStrategy, oldNode, newNode *corev1.Node) bool
- func RunNodePreUpdateExtenders(strategy *configuration.ColocationStrategy, node *corev1.Node, ...)
- func RunNodePrepareExtenders(strategy *configuration.ColocationStrategy, node *corev1.Node, ...)
- func RunNodeStatusCheckExtenders(strategy *configuration.ColocationStrategy, oldNode, newNode *corev1.Node) bool
- func RunResourceCalculateExtenders(nr *NodeResource, strategy *configuration.ColocationStrategy, ...)
- func RunResourceResetExtenders(nr *NodeResource, node *corev1.Node, message string)
- func RunSetupExtenders(opt *Option)
- func UnregisterNodeMetaCheckExtender(name string)
- func UnregisterNodePreUpdateExtender(name string)
- func UnregisterNodePrepareExtender(name string)
- func UnregisterNodeStatusCheckExtender(name string)
- func UnregisterResourceCalculateExtender(name string)
- func UnregisterSetupExtender(name string)
- type FilterFn
- type NodeMetaCheckPlugin
- type NodePreUpdatePlugin
- type NodePreparePlugin
- type NodeResource
- type NodeStatusCheckPlugin
- type Option
- func (o *Option) CompleteController(r reconcile.Reconciler) error
- func (o *Option) WithClient(c client.Client) *Option
- func (o *Option) WithControllerBuilder(b *builder.Builder) *Option
- func (o *Option) WithManager(mgr ctrl.Manager) *Option
- func (o *Option) WithRecorder(r record.EventRecorder) *Option
- func (o *Option) WithScheme(s *runtime.Scheme) *Option
- type Plugin
- type PluginConfig
- type PluginRegistry
- type ResourceCalculatePlugin
- type ResourceItem
- type ResourceMetrics
- type ResourceResetPlugin
- type SetupPlugin
- type SyncContext
Constants ¶
This section is empty.
Variables ¶
var AllPass = func(string) bool { return true }
Functions ¶
func RegisterNodeMetaCheckExtender ¶ added in v1.4.0
func RegisterNodeMetaCheckExtender(filter FilterFn, plugins ...NodeMetaCheckPlugin)
func RegisterNodePreUpdateExtender ¶ added in v1.4.0
func RegisterNodePreUpdateExtender(filter FilterFn, plugins ...NodePreUpdatePlugin)
func RegisterNodePrepareExtender ¶
func RegisterNodePrepareExtender(filter FilterFn, plugins ...NodePreparePlugin)
func RegisterNodeStatusCheckExtender ¶ added in v1.4.0
func RegisterNodeStatusCheckExtender(filter FilterFn, plugins ...NodeStatusCheckPlugin)
func RegisterResourceCalculateExtender ¶
func RegisterResourceCalculateExtender(filter FilterFn, plugins ...ResourceCalculatePlugin)
func RegisterSetupExtender ¶ added in v1.3.0
func RegisterSetupExtender(filter FilterFn, plugins ...SetupPlugin)
func RunNodeMetaCheckExtenders ¶ added in v1.4.0
func RunNodeMetaCheckExtenders(strategy *configuration.ColocationStrategy, oldNode, newNode *corev1.Node) bool
func RunNodePreUpdateExtenders ¶ added in v1.4.0
func RunNodePreUpdateExtenders(strategy *configuration.ColocationStrategy, node *corev1.Node, nr *NodeResource)
func RunNodePrepareExtenders ¶
func RunNodePrepareExtenders(strategy *configuration.ColocationStrategy, node *corev1.Node, nr *NodeResource)
func RunNodeStatusCheckExtenders ¶ added in v1.4.0
func RunNodeStatusCheckExtenders(strategy *configuration.ColocationStrategy, oldNode, newNode *corev1.Node) bool
func RunResourceCalculateExtenders ¶
func RunResourceCalculateExtenders(nr *NodeResource, strategy *configuration.ColocationStrategy, node *corev1.Node, podList *corev1.PodList, resourceMetrics *ResourceMetrics)
func RunResourceResetExtenders ¶
func RunResourceResetExtenders(nr *NodeResource, node *corev1.Node, message string)
func RunSetupExtenders ¶ added in v1.3.0
func RunSetupExtenders(opt *Option)
func UnregisterNodeMetaCheckExtender ¶ added in v1.4.0
func UnregisterNodeMetaCheckExtender(name string)
func UnregisterNodePreUpdateExtender ¶ added in v1.4.0
func UnregisterNodePreUpdateExtender(name string)
func UnregisterNodePrepareExtender ¶
func UnregisterNodePrepareExtender(name string)
func UnregisterNodeStatusCheckExtender ¶ added in v1.4.0
func UnregisterNodeStatusCheckExtender(name string)
func UnregisterResourceCalculateExtender ¶
func UnregisterResourceCalculateExtender(name string)
func UnregisterSetupExtender ¶ added in v1.3.0
func UnregisterSetupExtender(name string)
Types ¶
type NodeMetaCheckPlugin ¶ added in v1.4.0
type NodeMetaCheckPlugin interface { Plugin NeedSyncMeta(strategy *configuration.ColocationStrategy, oldNode, newNode *corev1.Node) (bool, string) }
type NodePreUpdatePlugin ¶ added in v1.4.0
type NodePreUpdatePlugin interface { Plugin PreUpdate(strategy *configuration.ColocationStrategy, node *corev1.Node, nr *NodeResource) error }
NodePreUpdatePlugin implements preprocessing for the calculated results called before updating the Node. There are mainly two use cases for this stage: 1. A plugin may prepare and update some Objects like CRDs before updating the Node obj (NodePrepare and NodeXXXCheck). 2. A plugin may need to mutate the internal NodeResource object before updating the Node object. It differs from the NodePreparePlugin in that a NodePreUpdatePlugin will be invoked only once in one loop (so the plugin should consider implement a retry login itself if needed), while the NodePreparePlugin is not expected to update other objects or mutate the NodeResource.
type NodePreparePlugin ¶
type NodePreparePlugin interface { Plugin Prepare(strategy *configuration.ColocationStrategy, node *corev1.Node, nr *NodeResource) error }
NodePreparePlugin implements node resource preparing for the calculated results. For example, assign extended resources in the node allocatable. It is invoked each time the controller tries updating the latest NodeResource object with calculated results. NOTE: The Prepare should be idempotent since it can be called multiple times in one reconciliation.
type NodeResource ¶
type NodeResource struct { Resources map[corev1.ResourceName]*resource.Quantity `json:"resources,omitempty"` ZoneResources map[string]corev1.ResourceList `json:"zoneResources,omitempty"` Labels map[string]string `json:"labels,omitempty"` Annotations map[string]string `json:"annotations,omitempty"` Messages map[corev1.ResourceName]string `json:"messages,omitempty"` Resets map[corev1.ResourceName]bool `json:"resets,omitempty"` }
func NewNodeResource ¶
func NewNodeResource(items ...ResourceItem) *NodeResource
func (*NodeResource) Delete ¶
func (nr *NodeResource) Delete(items ...ResourceItem)
func (*NodeResource) Get ¶
func (nr *NodeResource) Get(name corev1.ResourceName) *resource.Quantity
func (*NodeResource) Set ¶
func (nr *NodeResource) Set(items ...ResourceItem)
func (*NodeResource) SetResourceList ¶
func (nr *NodeResource) SetResourceList(rl corev1.ResourceList, message string)
type NodeStatusCheckPlugin ¶ added in v1.4.0
type NodeStatusCheckPlugin interface { Plugin NeedSync(strategy *configuration.ColocationStrategy, oldNode, newNode *corev1.Node) (bool, string) }
NodeStatusCheckPlugin implements the check of resource updating. For example, trigger an update if the values of the current is more than 10% different with the former.
type Option ¶ added in v1.3.0
type Option struct { Client client.Client Recorder record.EventRecorder Scheme *runtime.Scheme Builder *builder.Builder }
func (*Option) CompleteController ¶ added in v1.4.0
func (o *Option) CompleteController(r reconcile.Reconciler) error
func (*Option) WithControllerBuilder ¶ added in v1.4.0
func (*Option) WithRecorder ¶ added in v1.3.0
func (o *Option) WithRecorder(r record.EventRecorder) *Option
type Plugin ¶
type Plugin interface {
Name() string
}
Plugin has its name. Plugins in a registry are executed in order of the registration.
type PluginConfig ¶
type PluginConfig struct {
Plugin Plugin
}
type PluginRegistry ¶
func NewRegistry ¶
func NewRegistry(registryName string, plugins ...Plugin) *PluginRegistry
func (*PluginRegistry) GetAll ¶
func (r *PluginRegistry) GetAll() []Plugin
func (*PluginRegistry) MustRegister ¶
func (r *PluginRegistry) MustRegister(plugins ...Plugin)
func (*PluginRegistry) Size ¶
func (r *PluginRegistry) Size() int
func (*PluginRegistry) Unregister ¶
func (r *PluginRegistry) Unregister(name string)
type ResourceCalculatePlugin ¶
type ResourceCalculatePlugin interface { ResourceResetPlugin Calculate(strategy *configuration.ColocationStrategy, node *corev1.Node, podList *corev1.PodList, metrics *ResourceMetrics) ([]ResourceItem, error) }
ResourceCalculatePlugin implements resource counting and overcommitment algorithms. It implements Reset which can be invoked when the calculated resources need a reset. A ResourceCalculatePlugin can handle the case when the metrics are abnormal by implementing degraded calculation.
type ResourceItem ¶
type ResourceItem struct { Name corev1.ResourceName `json:"name,omitempty"` Quantity *resource.Quantity `json:"quantity,omitempty"` ZoneQuantity map[string]resource.Quantity `json:"zoneQuantity,omitempty"` Labels map[string]string `json:"labels,omitempty"` Annotations map[string]string `json:"annotations,omitempty"` Message string `json:"message,omitempty"` // the message about the resource calculation Reset bool `json:"reset,omitempty"` // whether to reset the resource or not }
type ResourceMetrics ¶
type ResourceMetrics struct { NodeMetric *slov1alpha1.NodeMetric `json:"nodeMetric,omitempty"` // extended metrics Extensions *slov1alpha1.ExtensionsMap `json:"extensions,omitempty"` }
type ResourceResetPlugin ¶
type ResourceResetPlugin interface { Plugin Reset(node *corev1.Node, message string) []ResourceItem }
type SetupPlugin ¶ added in v1.3.0
SetupPlugin implements setup for the plugin. The framework exposes the kube ClientSet and controller builder to the plugins thus the plugins can set up their necessary clients, add new watches and initialize their internal states. The Setup of each plugin will be called before other extension stages and invoked only once.
type SyncContext ¶
type SyncContext struct {
// contains filtered or unexported fields
}
func NewSyncContext ¶
func NewSyncContext() *SyncContext
func (*SyncContext) Delete ¶
func (s *SyncContext) Delete(key string)
func (*SyncContext) WithContext ¶
func (s *SyncContext) WithContext(m map[string]time.Time) *SyncContext