forked from astro/skyflake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-server.nix
139 lines (125 loc) · 3.33 KB
/
example-server.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{ instance }:
{ config, lib, pkgs, ... }:
{
microvm = {
vcpu = 2;
mem = 4096;
shares = [
{
tag = "ro-store";
source = "/nix/store";
mountPoint = "/nix/.ro-store";
}
];
volumes = [
{
image = "example${toString instance}-persist.img";
mountPoint = "/";
size = 20 * 1024;
fsType = "btrfs"; # needed for some seaweedfs optimizations.
}
{
image = "example${toString instance}-ceph.img";
mountPoint = null;
size = 20 * 1024;
}
];
writableStoreOverlay = "/nix/.rw-store";
interfaces = [ {
id = "eth0";
type = "bridge";
mac = "02:00:00:00:00:0${toString instance}";
bridge = "virbr0";
} ];
};
networking.hostName = "example${toString instance}";
users.users.root.password = "";
networking.firewall.enable = true;
networking.useDHCP = false;
networking.useNetworkd = true;
systemd.network = {
netdevs = {
# a bridge to connect microvms
"br0" = {
netdevConfig = {
Kind = "bridge";
Name = "br0";
};
};
};
networks = {
# uplink
"00-eth" = {
matchConfig.MACAddress = (builtins.head config.microvm.interfaces).mac;
networkConfig.Bridge = "br0";
};
# bridge is a dumb switch without addresses on the host
"01-br0" = {
matchConfig.Name = "br0";
networkConfig = {
DHCP = "ipv4";
IPv6AcceptRA = true;
};
addresses = [ {
Address = "fec0::${toString instance}/64";
} ];
};
};
};
skyflake = {
nodes = builtins.listToAttrs (
map (instance: {
name = "example${toString instance}";
value.address = "[fec0::${toString instance}]";
}) [ 1 2 3 ]
);
storage.seaweedfs = {
enable = false;
volumeStorage.encrypt = true;
# example mount below.
# mounts."/mnt".mountSource = "/filesystems/1a32bfd9-0cbc-430a-a28a-d9fd862e9ebc";
filer.db.etcd = {
enable = true;
certFile = example/certs/default.pem;
keyFile = example/certs/default-key.pem;
trustedCaFile = example/certs/ca.pem;
};
};
storage.ceph = {
enable = true;
fsid = "8364da79-5e03-49ae-82ea-7d936278cb0f";
monKeyring = example/ceph.mon.keyring;
adminKeyring = example/ceph.client.admin.keyring;
osds = [ {
id = instance;
fsid = "8e4ae689-5c15-4381-bd75-19de743378e${toString instance}";
path = "/dev/vdb";
deviceClass = "ssd";
keyfile = toString (./example + "/osd.${toString instance}.keyring");
} ];
rbdPools.microvms = {
params = { size = 2; class = "ssd"; };
};
cephfs.skyflake.metaParams = { size = 2; class = "ssd"; };
};
nomad = {
servers = builtins.attrNames config.skyflake.nodes;
client.meta = {
example-deployment = "yes";
};
};
users = {
test = {
uid = 1000;
sshKeys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGJJTSJdpDh82486uPiMhhyhnci4tScp5uUe7156MBC8 astro"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPRRdToCDUupkkwI+crB3fGDwdBIFkDsBHjOImn+qsjg openpgp:0xE8D3D833"
];
};
};
};
environment.systemPackages = with pkgs; [
tcpdump
nmap
];
}