mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-02-22 07:50:04 -05:00
operator: allow increasing number of node upgrade budget
This commit is contained in:
parent
37900d9d9c
commit
11c02980be
@ -54,6 +54,11 @@ spec:
|
||||
description: KubernetesComponentsReference is a reference to the ConfigMap
|
||||
containing the Kubernetes components to use for all nodes.
|
||||
type: string
|
||||
maxNodeBudget:
|
||||
description: MaxNodeBudget is the maximum number of nodes that can
|
||||
be created simultaneously.
|
||||
format: int32
|
||||
type: integer
|
||||
type: object
|
||||
status:
|
||||
description: NodeVersionStatus defines the observed state of NodeVersion.
|
||||
|
@ -21,6 +21,8 @@ type NodeVersionSpec struct {
|
||||
KubernetesComponentsReference string `json:"kubernetesComponentsReference,omitempty"`
|
||||
// KubernetesClusterVersion is the advertised Kubernetes version of the cluster.
|
||||
KubernetesClusterVersion string `json:"kubernetesClusterVersion,omitempty"`
|
||||
// MaxNodeBudget is the maximum number of nodes that can be created simultaneously.
|
||||
MaxNodeBudget uint32 `json:"maxNodeBudget,omitempty"`
|
||||
}
|
||||
|
||||
// NodeVersionStatus defines the observed state of NodeVersion.
|
||||
|
@ -54,6 +54,11 @@ spec:
|
||||
description: KubernetesComponentsReference is a reference to the ConfigMap
|
||||
containing the Kubernetes components to use for all nodes.
|
||||
type: string
|
||||
maxNodeBudget:
|
||||
description: MaxNodeBudget is the maximum number of nodes that can
|
||||
be created simultaneously.
|
||||
format: int32
|
||||
type: integer
|
||||
type: object
|
||||
status:
|
||||
description: NodeVersionStatus defines the observed state of NodeVersion.
|
||||
|
@ -13,4 +13,4 @@ kind: Kustomization
|
||||
images:
|
||||
- name: controller
|
||||
newName: ghcr.io/edgelesssys/constellation/node-operator
|
||||
newTag: v0.0.0
|
||||
newTag: v0.0.1
|
||||
|
@ -38,8 +38,6 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// nodeOverprovisionLimit is the maximum number of extra nodes created during the update procedure at any point in time.
|
||||
nodeOverprovisionLimit = 1
|
||||
// nodeJoinTimeout is the time limit pending nodes have to join the cluster before being terminated.
|
||||
nodeJoinTimeout = time.Minute * 30
|
||||
// nodeLeaveTimeout is the time limit pending nodes have to leave the cluster and being terminated.
|
||||
@ -161,9 +159,14 @@ func (r *NodeVersionReconciler) Reconcile(ctx context.Context, req ctrl.Request)
|
||||
// - being created (joining)
|
||||
// - being destroyed (leaving)
|
||||
// - heirs to outdated nodes
|
||||
extraNodes := len(groups.Heirs) + len(groups.AwaitingAnnotation) + len(pendingNodeList.Items)
|
||||
extraNodes := uint32(len(groups.Heirs) + len(groups.AwaitingAnnotation) + len(pendingNodeList.Items))
|
||||
// newNodesBudget is the maximum number of new nodes that can be created in this Reconcile call.
|
||||
var newNodesBudget int
|
||||
var newNodesBudget uint32
|
||||
nodeOverprovisionLimit := uint32(1)
|
||||
// Use user definable value if it makes sense
|
||||
if desiredNodeVersion.Spec.MaxNodeBudget > 0 {
|
||||
nodeOverprovisionLimit = desiredNodeVersion.Spec.MaxNodeBudget
|
||||
}
|
||||
if extraNodes < nodeOverprovisionLimit {
|
||||
newNodesBudget = nodeOverprovisionLimit - extraNodes
|
||||
}
|
||||
@ -743,7 +746,7 @@ func (r *NodeVersionReconciler) tryUpdateStatus(ctx context.Context, name types.
|
||||
}
|
||||
|
||||
// nodeVersionStatus generates the NodeVersion.Status field given node groups and the budget for new nodes.
|
||||
func nodeVersionStatus(scheme *runtime.Scheme, groups nodeGroups, pendingNodes []updatev1alpha1.PendingNode, invalidNodes []corev1.Node, newNodesBudget int) updatev1alpha1.NodeVersionStatus {
|
||||
func nodeVersionStatus(scheme *runtime.Scheme, groups nodeGroups, pendingNodes []updatev1alpha1.PendingNode, invalidNodes []corev1.Node, newNodesBudget uint32) updatev1alpha1.NodeVersionStatus {
|
||||
var status updatev1alpha1.NodeVersionStatus
|
||||
outdatedCondition := metav1.Condition{
|
||||
Type: updatev1alpha1.ConditionOutdated,
|
||||
@ -821,7 +824,7 @@ func nodeVersionStatus(scheme *runtime.Scheme, groups nodeGroups, pendingNodes [
|
||||
}
|
||||
status.Pending = append(status.Pending, *pendingRef)
|
||||
}
|
||||
status.Budget = uint32(newNodesBudget)
|
||||
status.Budget = newNodesBudget
|
||||
return status
|
||||
}
|
||||
|
||||
@ -941,5 +944,5 @@ type newNodeConfig struct {
|
||||
outdatedNodes []corev1.Node
|
||||
pendingNodes []updatev1alpha1.PendingNode
|
||||
scalingGroupByID map[string]updatev1alpha1.ScalingGroup
|
||||
newNodesBudget int
|
||||
newNodesBudget uint32
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ func TestCreateNewNodes(t *testing.T) {
|
||||
outdatedNodes []corev1.Node
|
||||
pendingNodes []updatev1alpha1.PendingNode
|
||||
scalingGroupByID map[string]updatev1alpha1.ScalingGroup
|
||||
budget int
|
||||
budget uint32
|
||||
wantCreateCalls []string
|
||||
}{
|
||||
"no outdated nodes": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user