Let operator manage autoscaling of node groups

This commit is contained in:
katexochen 2022-09-15 16:48:32 +02:00 committed by Paul Meyer
parent 67d9be38d7
commit e301f575df
18 changed files with 499 additions and 42 deletions

View file

@ -18,6 +18,8 @@ type AutoscalingStrategySpec struct {
DeploymentName string `json:"deploymentName"`
// DeploymentNamespace defines the namespace of the autoscaler deployment.
DeploymentNamespace string `json:"deploymentNamespace"`
// AutoscalerExtraArgs defines extra arguments to be passed to the autoscaler.
AutoscalerExtraArgs map[string]string `json:"autoscalerExtraArgs,omitempty"`
}
// AutoscalingStrategyStatus defines the observed state of AutoscalingStrategy.

View file

@ -13,6 +13,11 @@ import (
const (
// ConditionOutdated is used to signal outdated scaling groups.
ConditionOutdated = "Outdated"
// WorkerRole is used to signal worker scaling groups.
WorkerRole NodeRole = "Worker"
// ControlPlaneRole is used to signal control plane scaling groups.
ControlPlaneRole NodeRole = "ControlPlane"
)
// ScalingGroupSpec defines the desired state of ScalingGroup.
@ -21,10 +26,22 @@ type ScalingGroupSpec struct {
NodeImage string `json:"nodeImage,omitempty"`
// GroupID is the CSP specific, canonical identifier of a scaling group.
GroupID string `json:"groupId,omitempty"`
// AutoscalerGroupName is name that is expected by the autoscaler.
AutoscalerGroupName string `json:"autoscalerGroupName,omitempty"`
// Autoscaling specifies wether the scaling group should automatically scale using the cluster-autoscaler.
Autoscaling bool `json:"autoscaling,omitempty"`
// Min is the minimum number of nodes in the scaling group (used by cluster-autoscaler).
Min int32 `json:"min,omitempty"`
// Max is the maximum number of autoscaled nodes in the scaling group (used by cluster-autoscaler).
Max int32 `json:"max,omitempty"`
// Role is the role of the nodes in the scaling group.
Role NodeRole `json:"role,omitempty"`
}
// NodeRole is the role of a node.
// +kubebuilder:validation:Enum=Worker;ControlPlane
type NodeRole string
// ScalingGroupStatus defines the observed state of ScalingGroup.
type ScalingGroupStatus struct {
// ImageReference is the image currently used for newly created nodes in this scaling group.

View file

@ -16,7 +16,7 @@ func (in *AutoscalingStrategy) DeepCopyInto(out *AutoscalingStrategy) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
in.Spec.DeepCopyInto(&out.Spec)
out.Status = in.Status
}
@ -73,6 +73,13 @@ func (in *AutoscalingStrategyList) DeepCopyObject() runtime.Object {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AutoscalingStrategySpec) DeepCopyInto(out *AutoscalingStrategySpec) {
*out = *in
if in.AutoscalerExtraArgs != nil {
in, out := &in.AutoscalerExtraArgs, &out.AutoscalerExtraArgs
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoscalingStrategySpec.