Documentation ¶
Index ¶
- Constants
- Variables
- func FilterActiveInstances(instances []*cluster.Instance) []*cluster.Instance
- func GetInstanceFromTemplate(template *cluster.InstanceTemplateSpec, parentObject runtime.Object, ...) (*cluster.Instance, error)
- func GetSecretsFromTemplate(template *cluster.InstanceTemplateSpec, parentObject runtime.Object, ...) ([]v1.Secret, error)
- func InstanceKey(instance *cluster.Instance) string
- func IsInstanceActive(p *cluster.Instance) bool
- type ActiveInstances
- type InstanceControlInterface
- type InstanceControllerRefManager
- func (m *InstanceControllerRefManager) AdoptInstance(instance *cluster.Instance) error
- func (m *InstanceControllerRefManager) Classify(instances []*cluster.Instance) (matchesAndControlled []*cluster.Instance, ...)
- func (m *InstanceControllerRefManager) ReleaseInstance(instance *cluster.Instance) error
- type RealInstanceControl
- func (r RealInstanceControl) BindReservedInstance(ri *cluster.ReservedInstance, instance *cluster.Instance, unbind bool) (updatedRI *cluster.ReservedInstance, err error)
- func (r RealInstanceControl) CreateInstances(namespace string, template *cluster.InstanceTemplateSpec, ...) error
- func (r RealInstanceControl) CreateInstancesOnNode(nodeName, namespace string, template *cluster.InstanceTemplateSpec, ...) error
- func (r RealInstanceControl) CreateInstancesWithControllerRef(namespace string, template *cluster.InstanceTemplateSpec, ...) error
- func (r RealInstanceControl) DeleteInstance(namespace string, instanceID string, object runtime.Object) error
- func (r RealInstanceControl) PatchInstance(namespace, name string, data []byte) error
- func (r RealInstanceControl) UnbindInstanceWithReservedInstance(instance *cluster.Instance) (err error)
Constants ¶
const ( // FailedCreateInstanceReason is added in an event and in a replica set condition // when a instance for a replica set is failed to be created. FailedCreateInstanceReason = "FailedCreate" // SuccessfulCreateInstanceReason is added in an event when a instance for a replica set // is successfully created. SuccessfulCreateInstanceReason = "SuccessfulCreate" // FailedDeleteInstanceReason is added in an event and in a replica set condition // when a instance for a replica set is failed to be deleted. FailedDeleteInstanceReason = "FailedDelete" // SuccessfulDeleteInstanceReason is added in an event when a instance for a replica set // is successfully deleted. SuccessfulDeleteInstanceReason = "SuccessfulDelete" )
Reasons for instance events
Variables ¶
var (
CSRToken = cluster.AnnotationPrefix + "csr"
)
Functions ¶
func FilterActiveInstances ¶
FilterActiveInstances returns instances that have not terminated.
func GetInstanceFromTemplate ¶
func GetInstanceFromTemplate(template *cluster.InstanceTemplateSpec, parentObject runtime.Object, controllerRef *metav1.OwnerReference) (*cluster.Instance, error)
func GetSecretsFromTemplate ¶
func GetSecretsFromTemplate(template *cluster.InstanceTemplateSpec, parentObject runtime.Object, controllerRef *metav1.OwnerReference) ([]v1.Secret, error)
func InstanceKey ¶
func IsInstanceActive ¶
Types ¶
type ActiveInstances ¶
ActiveInstances type allows custom sorting of instances so a controller can pick the best ones to delete.
func (ActiveInstances) Len ¶
func (s ActiveInstances) Len() int
func (ActiveInstances) Less ¶
func (s ActiveInstances) Less(i, j int) bool
func (ActiveInstances) Swap ¶
func (s ActiveInstances) Swap(i, j int)
type InstanceControlInterface ¶
type InstanceControlInterface interface { // CreateInstances creates new instances according to the spec. CreateInstances(namespace string, template *cluster.InstanceTemplateSpec, object runtime.Object) error // CreateInstancesOnNode creates a new instance according to the spec on the specified node. CreateInstancesOnNode(nodeName, namespace string, template *cluster.InstanceTemplateSpec, object runtime.Object) error // CreateInstancesWithControllerRef creates new instances according to the spec, and sets object as the instance's controller. CreateInstancesWithControllerRef(namespace string, template *cluster.InstanceTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error // DeleteInstance deletes the instance identified by instanceID. DeleteInstance(namespace string, instanceID string, object runtime.Object) error // PatchInstance patches the instance. PatchInstance(namespace, name string, data []byte) error // Unbind UnbindInstanceWithReservedInstance(instance *cluster.Instance) error BindReservedInstance(ri *cluster.ReservedInstance, instance *cluster.Instance, unbind bool) (updatedRI *cluster.ReservedInstance, err error) }
InstanceControlInterface is an interface that knows how to add or delete instances created as an interface to allow testing.
type InstanceControllerRefManager ¶
type InstanceControllerRefManager struct {
// contains filtered or unexported fields
}
func NewInstanceControllerRefManager ¶
func NewInstanceControllerRefManager( instanceControl InstanceControlInterface, controllerObject metav1.ObjectMeta, controllerSelector labels.Selector, controllerKind schema.GroupVersionKind, ) *InstanceControllerRefManager
NewInstanceControllerRefManager returns a InstanceControllerRefManager that exposes methods to manage the controllerRef of instances.
func (*InstanceControllerRefManager) AdoptInstance ¶
func (m *InstanceControllerRefManager) AdoptInstance(instance *cluster.Instance) error
AdoptInstance sends a patch to take control of the instance. It returns the error if the patching fails.
func (*InstanceControllerRefManager) Classify ¶
func (m *InstanceControllerRefManager) Classify(instances []*cluster.Instance) ( matchesAndControlled []*cluster.Instance, matchesNeedsController []*cluster.Instance, controlledDoesNotMatch []*cluster.Instance)
Classify first filters out inactive instances, then it classify the remaining instances into three categories: 1. matchesAndControlled are the instances whose labels match the selector of the RC, and have a controllerRef pointing to the controller 2. matchesNeedsController are the instances whose labels match the RC, but don't have a controllerRef. (Instances with matching labels but with a controllerRef pointing to other object are ignored) 3. controlledDoesNotMatch are the instances that have a controllerRef pointing to the controller, but their labels no longer match the selector.
func (*InstanceControllerRefManager) ReleaseInstance ¶
func (m *InstanceControllerRefManager) ReleaseInstance(instance *cluster.Instance) error
ReleaseInstance sends a patch to free the instance from the control of the controller. It returns the error if the patching fails. 404 and 422 errors are ignored.
type RealInstanceControl ¶
type RealInstanceControl struct { KubeClient clientset.Interface Recorder record.EventRecorder }
RealInstanceControl is the default implementation of InstanceControlInterface.
func (RealInstanceControl) BindReservedInstance ¶
func (r RealInstanceControl) BindReservedInstance(ri *cluster.ReservedInstance, instance *cluster.Instance, unbind bool) (updatedRI *cluster.ReservedInstance, err error)
Update both reserved instance and instance. Get related reserved instance if not provided. Update only instance if no reserved instance provided or found
func (RealInstanceControl) CreateInstances ¶
func (r RealInstanceControl) CreateInstances(namespace string, template *cluster.InstanceTemplateSpec, object runtime.Object) error
func (RealInstanceControl) CreateInstancesOnNode ¶
func (r RealInstanceControl) CreateInstancesOnNode(nodeName, namespace string, template *cluster.InstanceTemplateSpec, object runtime.Object) error
func (RealInstanceControl) CreateInstancesWithControllerRef ¶
func (r RealInstanceControl) CreateInstancesWithControllerRef(namespace string, template *cluster.InstanceTemplateSpec, controllerObject runtime.Object, controllerRef *metav1.OwnerReference) error
func (RealInstanceControl) DeleteInstance ¶
func (RealInstanceControl) PatchInstance ¶
func (r RealInstanceControl) PatchInstance(namespace, name string, data []byte) error
func (RealInstanceControl) UnbindInstanceWithReservedInstance ¶
func (r RealInstanceControl) UnbindInstanceWithReservedInstance(instance *cluster.Instance) (err error)