mirror of
https://github.com/ubicloud/ubicloud.git
synced 2025-10-05 06:12:09 +08:00
To determine the total effective vCPU usage for each Kubernetes cluster, sum the vCPUs of all control plane nodes and all worker nodes via node pools. Initially, I implemented something similar to the PostgreSQL vCPU usage calculation to keep the entire logic within the database. (kubernetes_clusters_dataset.association_join(nodes: :vm).sum(:vcpus) || 0) + (kubernetes_clusters_dataset.association_join(nodepools: {nodes: :vm}).sum(:vcpus) || 0) The issue with summing vCPUs of all control plane and worker nodes is that it assumes all nodes are already created. Kubernetes clusters differ from PostgreSQL resources: node pools are created at the next labels of the nexus, not immediately in the assemble. If a customer creates many clusters at once, the vCPU usage will show as 0 until the strand runs and actually provisions the nodes. To handle this, I decided to base part of the calculation on the planned target node sizes (target_node_sizes) instead of relying solely on existing nodes. |
||
---|---|---|
.. | ||
clec | ||
lib | ||
model | ||
prog | ||
routes | ||
scheduling | ||
serializers | ||
cli_config.ru | ||
cli_spec.rb | ||
config_spec.rb | ||
coverage_helper.rb | ||
db_spec.rb | ||
monitor_smoke_test.rb | ||
resource_methods_spec.rb | ||
respirate_smoke_test.rb | ||
ruby_sdk_spec.rb | ||
spec_helper.rb | ||
thawed_mock.rb | ||
ubid_spec.rb |