ubicloud/serializers/kubernetes_cluster.rb
mohi-kalantari 61f98a4110 Use KubernetesNode instead of Vm in Kubernetes progs
All the logics related to k8s (provisioning, bootstrapping, upgrades)
now all rely on the KuberneteNode object. The former methods for Vm
are still kept in place until the code is deployed and in another
commit those parts with their DB tables will be removed altogether.

Code will no longer try to add vms to the join tables for the
many_to_many tables of both KubernetesCluster and KubernetesNodepool

Instead kubernetes_node object will be used to find the right Vms
of nodepools and clusters.
2025-08-28 10:36:02 +02:00

20 lines
624 B
Ruby

# frozen_string_literal: true
class Serializers::KubernetesCluster < Serializers::Base
def self.serialize_internal(kc, options = {})
base = {
id: kc.ubid,
name: kc.name,
location: kc.location.display_name,
display_state: kc.display_state,
cp_node_count: kc.cp_node_count,
node_size: kc.target_node_size,
version: kc.version
}
if options[:detailed]
base[:cp_vms] = Serializers::Vm.serialize(kc.cp_vms_via_nodes_dataset.all)
base[:nodepools] = Serializers::KubernetesNodepool.serialize(kc.nodepools_dataset.all, {detailed: true})
end
base
end
end