From 203f21ff2999a35f55ee11943741bf64a521d4d1 Mon Sep 17 00:00:00 2001 From: centra Date: Fri, 20 Mar 2026 16:29:34 +0900 Subject: [PATCH] Factor vm-cluster cluster state and export deployer artifacts --- flake.nix | 4 + nix/nodes/vm-cluster/cluster.nix | 101 ++++++++++++++++++ nix/nodes/vm-cluster/node01/configuration.nix | 97 +---------------- nix/nodes/vm-cluster/node02/configuration.nix | 97 +---------------- nix/nodes/vm-cluster/node03/configuration.nix | 97 +---------------- nix/test-cluster/flake.nix | 2 + 6 files changed, 110 insertions(+), 288 deletions(-) create mode 100644 nix/nodes/vm-cluster/cluster.nix diff --git a/flake.nix b/flake.nix index ed0aa98..5038175 100644 --- a/flake.nix +++ b/flake.nix @@ -400,6 +400,9 @@ description = "Label-aware service scheduler for PhotonCloud bare-metal fleets"; }; + vmClusterDeployerState = + self.nixosConfigurations.node01.config.system.build.plasmacloudDeployerClusterState; + # -------------------------------------------------------------------- # Default package: Build all servers # -------------------------------------------------------------------- @@ -423,6 +426,7 @@ self.packages.${system}.deployer-ctl self.packages.${system}.node-agent self.packages.${system}.fleet-scheduler + self.packages.${system}.vmClusterDeployerState ]; }; }; diff --git a/nix/nodes/vm-cluster/cluster.nix b/nix/nodes/vm-cluster/cluster.nix new file mode 100644 index 0000000..8eafc83 --- /dev/null +++ b/nix/nodes/vm-cluster/cluster.nix @@ -0,0 +1,101 @@ +{ ... }: + +{ + plasmacloud.cluster = { + enable = true; + name = "plasmacloud-vm-cluster"; + + nodes = { + node01 = { + role = "control-plane"; + ip = "192.168.100.11"; + services = [ "chainfire" "flaredb" "iam" ]; + labels = { + tier = "control-plane"; + platform = "vm-cluster"; + }; + pool = "control"; + nodeClass = "control-plane"; + failureDomain = "rack-a"; + nixProfile = "profiles/control-plane"; + installPlan = { + nixosConfiguration = "node01"; + diskoConfigPath = "nix/nodes/vm-cluster/node01/disko.nix"; + }; + raftPort = 2380; + apiPort = 2379; + }; + + node02 = { + role = "control-plane"; + ip = "192.168.100.12"; + services = [ "chainfire" "flaredb" "iam" ]; + labels = { + tier = "control-plane"; + platform = "vm-cluster"; + }; + pool = "control"; + nodeClass = "control-plane"; + failureDomain = "rack-b"; + nixProfile = "profiles/control-plane"; + installPlan = { + nixosConfiguration = "node02"; + diskoConfigPath = "nix/nodes/vm-cluster/node02/disko.nix"; + }; + raftPort = 2380; + apiPort = 2379; + }; + + node03 = { + role = "control-plane"; + ip = "192.168.100.13"; + services = [ "chainfire" "flaredb" "iam" ]; + labels = { + tier = "control-plane"; + platform = "vm-cluster"; + }; + pool = "control"; + nodeClass = "control-plane"; + failureDomain = "rack-c"; + nixProfile = "profiles/control-plane"; + installPlan = { + nixosConfiguration = "node03"; + diskoConfigPath = "nix/nodes/vm-cluster/node03/disko.nix"; + }; + raftPort = 2380; + apiPort = 2379; + }; + }; + + deployer = { + clusterId = "plasmacloud-vm-cluster"; + environment = "dev"; + + nodeClasses = { + control-plane = { + description = "Control-plane VM cluster nodes"; + nixProfile = "profiles/control-plane"; + roles = [ "control-plane" ]; + labels = { + tier = "control-plane"; + platform = "vm-cluster"; + }; + }; + }; + + pools = { + control = { + description = "VM cluster control-plane pool"; + nodeClass = "control-plane"; + labels = { + plane = "control"; + cluster = "vm-cluster"; + }; + }; + }; + }; + + bootstrap.initialPeers = [ "node01" "node02" "node03" ]; + bgp.asn = 64512; + }; +} diff --git a/nix/nodes/vm-cluster/node01/configuration.nix b/nix/nodes/vm-cluster/node01/configuration.nix index deca319..b32a2a0 100644 --- a/nix/nodes/vm-cluster/node01/configuration.nix +++ b/nix/nodes/vm-cluster/node01/configuration.nix @@ -2,6 +2,7 @@ { imports = [ + ../cluster.nix ./disko.nix ]; @@ -35,102 +36,6 @@ flaredbAddr = "192.168.100.11:2479"; }; - plasmacloud.cluster = { - enable = true; - name = "plasmacloud-vm-cluster"; - - nodes = { - node01 = { - role = "control-plane"; - ip = "192.168.100.11"; - services = [ "chainfire" "flaredb" "iam" ]; - labels = { - tier = "control-plane"; - platform = "vm-cluster"; - }; - pool = "control"; - nodeClass = "control-plane"; - failureDomain = "rack-a"; - nixProfile = "profiles/control-plane"; - installPlan = { - nixosConfiguration = "node01"; - diskoConfigPath = "nix/nodes/vm-cluster/node01/disko.nix"; - }; - raftPort = 2380; - apiPort = 2379; - }; - node02 = { - role = "control-plane"; - ip = "192.168.100.12"; - services = [ "chainfire" "flaredb" "iam" ]; - labels = { - tier = "control-plane"; - platform = "vm-cluster"; - }; - pool = "control"; - nodeClass = "control-plane"; - failureDomain = "rack-b"; - nixProfile = "profiles/control-plane"; - installPlan = { - nixosConfiguration = "node02"; - diskoConfigPath = "nix/nodes/vm-cluster/node02/disko.nix"; - }; - raftPort = 2380; - apiPort = 2379; - }; - node03 = { - role = "control-plane"; - ip = "192.168.100.13"; - services = [ "chainfire" "flaredb" "iam" ]; - labels = { - tier = "control-plane"; - platform = "vm-cluster"; - }; - pool = "control"; - nodeClass = "control-plane"; - failureDomain = "rack-c"; - nixProfile = "profiles/control-plane"; - installPlan = { - nixosConfiguration = "node03"; - diskoConfigPath = "nix/nodes/vm-cluster/node03/disko.nix"; - }; - raftPort = 2380; - apiPort = 2379; - }; - }; - - deployer = { - clusterId = "plasmacloud-vm-cluster"; - environment = "dev"; - - nodeClasses = { - control-plane = { - description = "Control-plane VM cluster nodes"; - nixProfile = "profiles/control-plane"; - roles = [ "control-plane" ]; - labels = { - tier = "control-plane"; - platform = "vm-cluster"; - }; - }; - }; - - pools = { - control = { - description = "VM cluster control-plane pool"; - nodeClass = "control-plane"; - labels = { - plane = "control"; - cluster = "vm-cluster"; - }; - }; - }; - }; - - bootstrap.initialPeers = [ "node01" "node02" "node03" ]; - bgp.asn = 64512; - }; - services.openssh.enable = true; users.users.root.openssh.authorizedKeys.keys = [ ]; diff --git a/nix/nodes/vm-cluster/node02/configuration.nix b/nix/nodes/vm-cluster/node02/configuration.nix index bd8f5bf..4f3f05d 100644 --- a/nix/nodes/vm-cluster/node02/configuration.nix +++ b/nix/nodes/vm-cluster/node02/configuration.nix @@ -2,6 +2,7 @@ { imports = [ + ../cluster.nix ./disko.nix ]; @@ -45,102 +46,6 @@ flaredbAddr = "192.168.100.11:2479"; }; - plasmacloud.cluster = { - enable = true; - name = "plasmacloud-vm-cluster"; - - nodes = { - node01 = { - role = "control-plane"; - ip = "192.168.100.11"; - services = [ "chainfire" "flaredb" "iam" ]; - labels = { - tier = "control-plane"; - platform = "vm-cluster"; - }; - pool = "control"; - nodeClass = "control-plane"; - failureDomain = "rack-a"; - nixProfile = "profiles/control-plane"; - installPlan = { - nixosConfiguration = "node01"; - diskoConfigPath = "nix/nodes/vm-cluster/node01/disko.nix"; - }; - raftPort = 2380; - apiPort = 2379; - }; - node02 = { - role = "control-plane"; - ip = "192.168.100.12"; - services = [ "chainfire" "flaredb" "iam" ]; - labels = { - tier = "control-plane"; - platform = "vm-cluster"; - }; - pool = "control"; - nodeClass = "control-plane"; - failureDomain = "rack-b"; - nixProfile = "profiles/control-plane"; - installPlan = { - nixosConfiguration = "node02"; - diskoConfigPath = "nix/nodes/vm-cluster/node02/disko.nix"; - }; - raftPort = 2380; - apiPort = 2379; - }; - node03 = { - role = "control-plane"; - ip = "192.168.100.13"; - services = [ "chainfire" "flaredb" "iam" ]; - labels = { - tier = "control-plane"; - platform = "vm-cluster"; - }; - pool = "control"; - nodeClass = "control-plane"; - failureDomain = "rack-c"; - nixProfile = "profiles/control-plane"; - installPlan = { - nixosConfiguration = "node03"; - diskoConfigPath = "nix/nodes/vm-cluster/node03/disko.nix"; - }; - raftPort = 2380; - apiPort = 2379; - }; - }; - - deployer = { - clusterId = "plasmacloud-vm-cluster"; - environment = "dev"; - - nodeClasses = { - control-plane = { - description = "Control-plane VM cluster nodes"; - nixProfile = "profiles/control-plane"; - roles = [ "control-plane" ]; - labels = { - tier = "control-plane"; - platform = "vm-cluster"; - }; - }; - }; - - pools = { - control = { - description = "VM cluster control-plane pool"; - nodeClass = "control-plane"; - labels = { - plane = "control"; - cluster = "vm-cluster"; - }; - }; - }; - }; - - bootstrap.initialPeers = [ "node01" "node02" "node03" ]; - bgp.asn = 64512; - }; - services.openssh.enable = true; users.users.root.openssh.authorizedKeys.keys = [ ]; diff --git a/nix/nodes/vm-cluster/node03/configuration.nix b/nix/nodes/vm-cluster/node03/configuration.nix index 8b31603..16644ee 100644 --- a/nix/nodes/vm-cluster/node03/configuration.nix +++ b/nix/nodes/vm-cluster/node03/configuration.nix @@ -2,6 +2,7 @@ { imports = [ + ../cluster.nix ./disko.nix ]; @@ -45,102 +46,6 @@ flaredbAddr = "192.168.100.11:2479"; }; - plasmacloud.cluster = { - enable = true; - name = "plasmacloud-vm-cluster"; - - nodes = { - node01 = { - role = "control-plane"; - ip = "192.168.100.11"; - services = [ "chainfire" "flaredb" "iam" ]; - labels = { - tier = "control-plane"; - platform = "vm-cluster"; - }; - pool = "control"; - nodeClass = "control-plane"; - failureDomain = "rack-a"; - nixProfile = "profiles/control-plane"; - installPlan = { - nixosConfiguration = "node01"; - diskoConfigPath = "nix/nodes/vm-cluster/node01/disko.nix"; - }; - raftPort = 2380; - apiPort = 2379; - }; - node02 = { - role = "control-plane"; - ip = "192.168.100.12"; - services = [ "chainfire" "flaredb" "iam" ]; - labels = { - tier = "control-plane"; - platform = "vm-cluster"; - }; - pool = "control"; - nodeClass = "control-plane"; - failureDomain = "rack-b"; - nixProfile = "profiles/control-plane"; - installPlan = { - nixosConfiguration = "node02"; - diskoConfigPath = "nix/nodes/vm-cluster/node02/disko.nix"; - }; - raftPort = 2380; - apiPort = 2379; - }; - node03 = { - role = "control-plane"; - ip = "192.168.100.13"; - services = [ "chainfire" "flaredb" "iam" ]; - labels = { - tier = "control-plane"; - platform = "vm-cluster"; - }; - pool = "control"; - nodeClass = "control-plane"; - failureDomain = "rack-c"; - nixProfile = "profiles/control-plane"; - installPlan = { - nixosConfiguration = "node03"; - diskoConfigPath = "nix/nodes/vm-cluster/node03/disko.nix"; - }; - raftPort = 2380; - apiPort = 2379; - }; - }; - - deployer = { - clusterId = "plasmacloud-vm-cluster"; - environment = "dev"; - - nodeClasses = { - control-plane = { - description = "Control-plane VM cluster nodes"; - nixProfile = "profiles/control-plane"; - roles = [ "control-plane" ]; - labels = { - tier = "control-plane"; - platform = "vm-cluster"; - }; - }; - }; - - pools = { - control = { - description = "VM cluster control-plane pool"; - nodeClass = "control-plane"; - labels = { - plane = "control"; - cluster = "vm-cluster"; - }; - }; - }; - }; - - bootstrap.initialPeers = [ "node01" "node02" "node03" ]; - bgp.asn = 64512; - }; - services.openssh.enable = true; users.users.root.openssh.authorizedKeys.keys = [ ]; diff --git a/nix/test-cluster/flake.nix b/nix/test-cluster/flake.nix index 6843d97..411f7b3 100644 --- a/nix/test-cluster/flake.nix +++ b/nix/test-cluster/flake.nix @@ -100,6 +100,8 @@ cluster = clusterHarness; vmGuestImage = vmGuestImage; vmBenchGuestImage = vmBenchGuestImage; + deployerClusterState = + self.nixosConfigurations.node06.config.system.build.plasmacloudDeployerClusterState; }; apps.${system}.cluster = {