Skip to content

Commit cebf26e

Browse files
committed
Start of modernization of skyflake.
1 parent 40fb7a4 commit cebf26e

14 files changed

Lines changed: 311 additions & 57 deletions

File tree

example-server.nix

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{ instance }:
22

3-
{ config, lib, pkgs, ... }:
3+
{ config, pkgs, ... }:
44

55
{
66
microvm = {
7-
vcpu = 2;
7+
vcpu = 4;
88
mem = 4096;
99

1010
shares = [ {
@@ -34,7 +34,7 @@
3434
networking.hostName = "example${toString instance}";
3535
users.users.root.password = "";
3636

37-
# TODO:
37+
# TODO:? Shoulld firewall be fixed?
3838
networking.firewall.enable = false;
3939

4040
networking.useDHCP = false;
@@ -64,7 +64,9 @@
6464
IPv6AcceptRA = true;
6565
};
6666
addresses = [ {
67-
addressConfig.Address = "fec0::${toString instance}/64";
67+
# TODO: addressConfig needs to be removed.
68+
# trace: warning: Using 'addressConfig' is deprecated! Move all attributes inside one level up and remove it.
69+
addressConfig.Address = "fec0::${toString instance}/64"; #
6870
} ];
6971
};
7072
};
@@ -78,22 +80,29 @@
7880
}) [ 1 2 3 ]
7981
);
8082

81-
storage.ceph = rec {
82-
fsid = "8364da79-5e03-49ae-82ea-7d936278cb0f";
83-
monKeyring = example/ceph.mon.keyring;
84-
adminKeyring = example/ceph.client.admin.keyring;
85-
osds = [ {
86-
id = instance;
87-
fsid = "8e4ae689-5c15-4381-bd75-19de743378e${toString instance}";
88-
path = "/dev/vdb";
89-
deviceClass = "ssd";
90-
keyfile = toString (./example + "/osd.${toString instance}.keyring");
91-
} ];
92-
rbdPools.microvms = {
93-
params = { size = 2; class = "ssd"; };
83+
84+
storage.seaweedfs = {
85+
enable = true;
86+
filer.db.etcd = {
87+
enable = true;
9488
};
95-
cephfs.skyflake.metaParams = { size = 2; class = "ssd"; };
9689
};
90+
#storage.ceph = {
91+
# fsid = "8364da79-5e03-49ae-82ea-7d936278cb0f";
92+
# monKeyring = example/ceph.mon.keyring;
93+
# adminKeyring = example/ceph.client.admin.keyring;
94+
# osds = [ {
95+
# id = instance;
96+
# fsid = "8e4ae689-5c15-4381-bd75-19de743378e${toString instance}";
97+
# path = "/dev/vdb";
98+
# deviceClass = "ssd";
99+
# keyfile = toString (./example + "/osd.${toString instance}.keyring");
100+
# } ];
101+
# rbdPools.microvms = {
102+
# params = { size = 2; class = "ssd"; };
103+
# };
104+
# cephfs.skyflake.metaParams = { size = 2; class = "ssd"; };
105+
#};
97106

98107
nomad = {
99108
servers = [ "example1" "example2" "example3" ];
@@ -107,6 +116,7 @@
107116
uid = 1000;
108117
sshKeys = [
109118
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGJJTSJdpDh82486uPiMhhyhnci4tScp5uUe7156MBC8 astro"
119+
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPRRdToCDUupkkwI+crB3fGDwdBIFkDsBHjOImn+qsjg openpgp:0xE8D3D833"
110120
];
111121
};
112122
};
@@ -115,4 +125,4 @@
115125
environment.systemPackages = with pkgs; [
116126
tcpdump
117127
];
118-
}
128+
}

flake.lock

Lines changed: 34 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
description = "Hyperconverged Infratructure for NixOS";
33

44
inputs = {
5-
microvm.url = "github:astro/microvm.nix";
6-
microvm.inputs.nixpkgs.follows = "nixpkgs";
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6+
microvm = {
7+
url = "github:astro/microvm.nix";
8+
inputs.nixpkgs.follows = "nixpkgs";
9+
};
10+
711
nix-cache-cut.url = "github:astro/nix-cache-cut";
812
};
913

@@ -14,14 +18,18 @@
1418
pkgs = nixpkgs.legacyPackages.${system};
1519

1620
in {
21+
formatter.${system} = pkgs.alejandra;
1722
packages.${system} = import ./pkgs/doc.nix {
1823
inherit pkgs self;
1924
};
2025

2126
nixosModules = {
2227
default = {
2328
imports = [
24-
./nixos-modules/storage/ceph/server.nix
29+
./nixos-modules/storage/seaweedfs/options.nix
30+
# ./nixos-modules/storage/seaweedfs/dbBackend/sqlite.nix
31+
./nixos-modules/storage/seaweedfs/dbBackend/etcd.nix
32+
# ./nixos-modules/storage/ceph/server.nix
2533
./nixos-modules/defaults.nix
2634
./nixos-modules/nodes.nix
2735
./nixos-modules/nomad.nix
@@ -71,9 +79,9 @@
7179

7280
make-ceph = {
7381
type = "app";
74-
program = toString (pkgs.callPackage ./pkgs/make-ceph.nix {});
82+
#program = toString (pkgs.callPackage ./pkgs/make-ceph.nix {});
7583
};
7684

7785
};
7886
};
79-
}
87+
}

nixos-modules/cache-cut.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ in
4141
systemd.services.skyflake-install-cache-gc = {
4242
wantedBy = [ "multi-user.target" ];
4343
requires = [ "nomad.service" ];
44-
path = with pkgs; [ nomad ];
44+
path = [ config.services.nomad.package ];
4545
script = ''
4646
nomad run -detach ${jobFile}
4747
'';

nixos-modules/nodes.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ in
99
description = ''
1010
All cluster nodes with their addresses, or at least those who
1111
run coordination servers (eg. nomad servers, ceph server,
12-
...).
12+
seaweedfs server ...).
1313
'';
1414
default = {};
1515
type = types.attrsOf (types.submodule {

nixos-modules/nomad.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ in
4242
config = {
4343
services.nomad = {
4444
enable = true;
45-
package = pkgs.nomad_1_4;
45+
package = pkgs.nomad_1_6; # nomad 1.6 is the newest version under an foss license.
4646
dropPrivileges = false;
4747
enableDocker = false;
4848

@@ -75,7 +75,7 @@ in
7575
# alternatives to the nomad web ui
7676
wander damon
7777
# needed for microvms
78-
virtiofsd ceph
78+
virtiofsd ceph seaweedfs
7979
jq kmod e2fsprogs
8080
];
8181
};

nixos-modules/ssh-deploy.nix

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{ config, lib, pkgs, ... }:
44

55
let
6-
inherit (config.skyflake.storage.ceph) cephfs;
6+
inherit (config.skyflake.storage.seaweedfs) seaweedfsMount;
77

88
debugShell = lib.optionalString config.skyflake.debug ''
99
set -x
@@ -143,8 +143,6 @@ let
143143
];
144144

145145
cfg = config.skyflake.deploy;
146-
gcCfg = config.skyflake.gc;
147-
148146
in {
149147
options.skyflake = with lib; {
150148
deploy = {
@@ -158,7 +156,7 @@ in {
158156

159157
binaryCachePath = mkOption {
160158
type = types.str;
161-
default = cephfs.skyflake-binary-cache.mountPoint;
159+
default = seaweedfsMount.skyflake-binary-cache.mountPoint;
162160
description = ''
163161
Directory which is mounted on all nodes that will be used to
164162
share the /nix/store with MicroVMs.
@@ -167,7 +165,7 @@ in {
167165

168166
sharedGcrootsPath = mkOption {
169167
type = types.str;
170-
default = cephfs.skyflake-gcroots.mountPoint;
168+
default = seaweedfsMount.skyflake-gcroots.mountPoint;
171169
description = ''
172170
Directory which is mounted on all nodes, is linked from
173171
/nix/var/nix/gcroots/, and contains links to all currently
@@ -211,9 +209,9 @@ in {
211209
'';
212210
};
213211
};
214-
212+
215213
config = {
216-
skyflake.storage.ceph.cephfs = {
214+
skyflake.storage.seaweedfs.seaweedfsMount = {
217215
skyflake-binary-cache.mountPoint = "/var/lib/skyflake/binary-cache";
218216
skyflake-gcroots.mountPoint = "/nix/var/nix/gcroots/skyflake";
219217
};

nixos-modules/storage/ceph/server.nix

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ let
5151

5252
in {
5353
options.skyflake.storage.ceph = {
54+
enable = lib.mkOption {
55+
type = lib.types.bool;
56+
default = false;
57+
example = true;
58+
};
5459
package = lib.mkPackageOption pkgs "ceph" { };
5560
fsid = lib.mkOption {
5661
type = lib.types.str;
@@ -100,7 +105,7 @@ in {
100105
};
101106
rbdPools = lib.mkOption {
102107
default = {};
103-
type = with lib.types; attrsOf (submodule ({ name, ... }: {
108+
type = with lib.types; attrsOf (submodule ({ ... }: {
104109
options = {
105110
params = poolParamsOpts;
106111
};
@@ -146,7 +151,9 @@ in {
146151
publicNetwork = clusterNetwork; #"0.0.0.0/0, ::/0";
147152
clusterNetwork = lib.concatStringsSep ", " (
148153
lib.concatMap ({ addresses ? [], ... }:
149-
lib.concatMap ({ addressConfig ? {}, ... }:
154+
# Needs to be changed because of
155+
# trace: warning: Using 'addressConfig' is deprecated! Move all attributes inside one level up and remove it.
156+
lib.concatMap ({ addressConfig ? {}, ... }:
150157
if addressConfig ? Address
151158
then [ addressConfig.Address ]
152159
else []
@@ -387,4 +394,4 @@ in {
387394
) cfg.cephfs
388395
));
389396
};
390-
}
397+
}

0 commit comments

Comments
 (0)