-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support NodeCountScaler #7258
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7258 +/- ##
==========================================
- Coverage 64.96% 64.88% -0.09%
==========================================
Files 337 345 +8
Lines 41723 41936 +213
==========================================
+ Hits 27107 27210 +103
- Misses 12260 12345 +85
- Partials 2356 2381 +25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
} | ||
cluster, _ := object.(*appsv1alpha1.Cluster) | ||
nodes := tree.List(&corev1.Node{}) | ||
// TODO(free6om): filter nodes that satisfy pod template spec of each component (by nodeSelector, nodeAffinity&nodeAntiAffinity, tolerations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are taints on some nodes, which cannot be tolerated by the Component, which situation will happen?
- Some Pods are in pending status.
- Some Nodes have multiple Pods deployed.
} | ||
statusList = append(statusList, status) | ||
} | ||
instanceset.MergeList(&statusList, &scaler.Status.ComponentStatuses, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems MergeList should be moved into a more suitable package.
/cherry-pick release-0.9 |
🤖 says: cherry pick action finished successfully 🎉! |
(cherry picked from commit 70df1e8)
fixed #6552
fixed #5795
Background
The requirement originated from here.
When the requirement was raised, the KB ClusterDefinition API had a WorkloadType field, where the underlying implementation relied on the native StatefulSet API of Kubernetes when the WorkloadType was
Consensus
,Replication
, orStateful
. In this context, the requirement could be fulfilled by introducing a new WorkloadType similar toDaemon
.Starting from version 0.8, KB introduced a new API architecture where there is no longer a field like WorkloadType. In the final implementation, all components are supported through the InstanceSet, which is a common Workload API. The InstanceSet directly manages more fundamental Kubernetes objects such as Pods and PVCs.
In the new API architecture, adding support for the Daemon type of workload is no longer as straightforward as before. The specific design is as follows.
Design
Goals
The above three points are the core features of DaemonSet.
API
For points 2 and 3 mentioned above, KB currently supports them, and they can be configured through relevant fields in APIs like Cluster.
For point 1, it is achieved by introducing an experimental API called NodeCountScalar.
Implementation
The NodeCountScalar Controller watches for Node and Cluster objects.
When a Create or Delete event occurs for a Node, it triggers a full-scale tuning of all NodeCountScalar objects.
When a Create or Update event occurs for a Cluster, it triggers the tuning of the corresponding NodeCountScalar object (if present).
During tuning, the NodeCountScalar Controller retrieves the current list of Nodes, where the length of the list becomes the DesiredReplicas.
Then, the Replicas value of the target ComponentSpec in the target Cluster object is updated to DesiredReplicas, achieving the goal of dynamically adjusting Replicas.
During the tuning process of the Cluster and its secondary resources, the Status field of the corresponding NodeCountScalar object is updated in real-time to observe the progress of dynamic adjustments.
Testing
Create the Cluster using the following command. At this time, the Replicas value of the ComponentSpec named "mysql" is 0, and the Cluster is in the Stopped state.
Run the following command to create the NodeAwareScaler:
Expected results