Compare commits
95 Commits
c7e7b2b06c
...
wip
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e111f5ea9
|
||
|
|
649e4033fd | ||
|
|
1b38004e03
|
||
|
|
d8ef4356a0
|
||
|
|
5dd5f2e4e0
|
||
|
|
84e8983974
|
||
|
|
24f4a8c2d9
|
||
|
|
a3cdaa9128
|
||
|
|
51295a23dc
|
||
|
|
11d8b93551
|
||
|
|
40b8742a80
|
||
|
|
32080e0e01
|
||
|
|
41668506cd | ||
|
|
63a988d1da
|
||
|
|
7c8d278923
|
||
|
|
297577471e
|
||
|
|
345ecfc7cf
|
||
|
|
889de9dbf6
|
||
|
|
65c2021473
|
||
|
|
b0f025d340
|
||
|
|
a00115fb4e
|
||
|
|
058f0cd59b
|
||
|
|
c8c18bde88
|
||
|
|
a36016e631
|
||
|
|
deaea6954e
|
||
|
|
c1ec96044e
|
||
|
|
cdb2994447
|
||
|
|
7416e412df
|
||
|
|
d14d8fe4a4
|
||
|
|
a4b20c1ead
|
||
|
|
b593fdc8a7
|
||
|
|
8f5f59ee87
|
||
|
|
fc32a42750
|
||
|
|
1d3d178fc8
|
||
|
|
e54f272a69
|
||
|
|
e09e659d91
|
||
|
|
3cc0fb1d3f
|
||
|
|
92727aa1f7
|
||
|
|
2a319deea0
|
||
|
|
d6f089bdb4
|
||
|
|
cce4f98125
|
||
|
|
612158c3e1
|
||
|
|
1ed3832730
|
||
|
|
f3b969642c
|
||
|
|
23d9bbb8a1
|
||
|
|
9e729a8cc6
|
||
|
|
3169822726
|
||
|
|
9b5fbadc44
|
||
|
|
ab1b2a70f3
|
||
|
|
4061d14651
|
||
|
|
361ec69a8b
|
||
|
|
f545376aec
|
||
|
|
dc80c06ee9
|
||
|
|
5d58d550d3
|
||
|
|
51e027ba67
|
||
|
|
37efcdb367
|
||
|
|
01d230bde6
|
||
|
|
383acd4fd2
|
||
|
|
7df824da6a
|
||
|
|
efbfe865e0
|
||
|
|
2314bef2ad
|
||
|
|
8e9bd9acc1
|
||
|
|
d924aa3a81
|
||
|
|
2bbf44e528
|
||
|
|
c289f46cc5
|
||
|
|
88b1c36c0d
|
||
|
|
dbd82b998d
|
||
|
|
1700c42926
|
||
|
|
3c20fd49f0
|
||
|
|
903c1c1f41
|
||
|
|
158c622840
|
||
|
|
ceb627bb35
|
||
|
|
a3f1dff351
|
||
|
|
46c8f5e0ce
|
||
|
|
3760bca64b
|
||
|
|
3396a4f482
|
||
|
|
773db6e567
|
||
|
|
6010867796
|
||
|
|
e9db45fb61
|
||
|
|
10cb394dde
|
||
|
|
14787d6730
|
||
|
|
19b2da0d40
|
||
|
|
95ec23126a
|
||
|
|
6897915455
|
||
|
|
868b9b9889
|
||
|
|
d0439a6d2f
|
||
|
|
fd15dc5bef
|
||
|
|
380ac011f1
|
||
|
|
f4891f345e
|
||
|
|
f8ad309c0b
|
||
|
|
6c07157f21
|
||
|
|
6aa87faecb
|
||
|
|
732e2cd296
|
||
|
|
ac07941b8e
|
||
|
|
fa59f17df5
|
12
nix/configuration/README.org
Normal file
12
nix/configuration/README.org
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
* To-do
|
||||||
|
** Perhaps use overlay for /etc for speedup
|
||||||
|
#+begin_src nix
|
||||||
|
system.etc.overlay.enable = true;
|
||||||
|
#+end_src
|
||||||
|
** read https://nixos.org/manual/nixos/stable/
|
||||||
|
** Performance for mini pc
|
||||||
|
#+begin_src nix
|
||||||
|
security.pam.loginLimits = [
|
||||||
|
{ domain = "@users"; item = "rtprio"; type = "-"; value = 1; }
|
||||||
|
];
|
||||||
|
#+end_src
|
||||||
@@ -246,31 +246,8 @@ in
|
|||||||
glew = (final.glew.override { enableEGL = false; });
|
glew = (final.glew.override { enableEGL = false; });
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
(final: prev: {
|
|
||||||
fwupd = prev.fwupd.overrideAttrs (
|
|
||||||
finalAttrs: prevAttrs: {
|
|
||||||
version = "2.1.5";
|
|
||||||
src = final.fetchFromGitHub {
|
|
||||||
owner = "fwupd";
|
|
||||||
repo = "fwupd";
|
|
||||||
tag = finalAttrs.version;
|
|
||||||
hash = "sha256-DzQ+N99ZmFRqZc2rN6PSqmoIMXUyrE8Kkn+KnT/AWPc=";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
})
|
|
||||||
(disableTests "onetbb") # oneTBB tests hang forever on machines with a single core (like my build virtual machine) https://github.com/uxlfoundation/oneTBB/issues/1557
|
(disableTests "onetbb") # oneTBB tests hang forever on machines with a single core (like my build virtual machine) https://github.com/uxlfoundation/oneTBB/issues/1557
|
||||||
(disableTests "aws-c-common") # aws-c-common tests time out on my build virtual machine but run fine on my laptop.
|
(disableTests "aws-c-common") # aws-c-common tests time out on my build virtual machine but run fine on my laptop.
|
||||||
|
|
||||||
# Works but probably sets python2's scipy to be python3:
|
|
||||||
#
|
|
||||||
# (final: prev: {
|
|
||||||
# pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
|
|
||||||
# (python-final: python-prev: {
|
|
||||||
# scipy = final.unoptimized.python3Packages.scipy;
|
|
||||||
# })
|
|
||||||
# ];
|
|
||||||
# })
|
|
||||||
];
|
];
|
||||||
|
|
||||||
# This option defines the first version of NixOS you have installed on this particular machine,
|
# This option defines the first version of NixOS you have installed on this particular machine,
|
||||||
|
|||||||
39
nix/configuration/flake.lock
generated
39
nix/configuration/flake.lock
generated
@@ -22,11 +22,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1780894562,
|
"lastModified": 1781152676,
|
||||||
"narHash": "sha256-c3430xwxwhHipl3jigUGMMBfpaMylDqytW/kdmB3ZGs=",
|
"narHash": "sha256-RxWs5ND31KzTG7wvMM+PMfUjyNpmIEr999lqNARaM5o=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "disko",
|
"repo": "disko",
|
||||||
"rev": "24fed06cac83bcc44ac8efbb57cab1a82fa0bedc",
|
"rev": "ff8702b4de27f72b4c78573dfb89ec74e36abdf1",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -170,11 +170,11 @@
|
|||||||
"rust-overlay": "rust-overlay_2"
|
"rust-overlay": "rust-overlay_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1783278211,
|
"lastModified": 1785248363,
|
||||||
"narHash": "sha256-/1u+MIQIge+cNPukQoK4Jp8nLuFZRbx4U+MyyxG0RpM=",
|
"narHash": "sha256-hx9Cn1vIa/h54t+s3ObO6+Z3xHSA1zc3YVRWxTZcigc=",
|
||||||
"ref": "refs/heads/main",
|
"ref": "refs/heads/main",
|
||||||
"rev": "9281ba7e10d362d4edb489d0df0e78936dfe7b58",
|
"rev": "0addf91edf82775a0dc5022a81065ef101305e64",
|
||||||
"revCount": 32,
|
"revCount": 38,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://code.fizz.buzz/talexander/nix_builder.git"
|
"url": "https://code.fizz.buzz/talexander/nix_builder.git"
|
||||||
},
|
},
|
||||||
@@ -185,11 +185,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1780749050,
|
"lastModified": 1785318670,
|
||||||
"narHash": "sha256-3av0pIjlOWQ6rDbNOmpUSvbNnJkGORQKKjb4LtCZsIY=",
|
"narHash": "sha256-dN6Ou5x/+23FZLEpYP3IffO+NyJFzUlGumt1uu3MMaY=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "a799d3e3886da994fa307f817a6bc705ae538eeb",
|
"rev": "0954f7ee2f6bb3dc7d4e3d0d8bcb8fd4bde4cfc5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -199,22 +199,6 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs-google": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1779893571,
|
|
||||||
"narHash": "sha256-wiwMyVCtmjRjlFCe2zaumCE6LRV9GzzN0ZH25NQkbAU=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "45f6cfaa4605b706c870e75bd74bdb5e97eee11e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "45f6cfaa4605b706c870e75bd74bdb5e97eee11e",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs-stable": {
|
"nixpkgs-stable": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1730741070,
|
"lastModified": 1730741070,
|
||||||
@@ -264,8 +248,7 @@
|
|||||||
"impermanence": "impermanence",
|
"impermanence": "impermanence",
|
||||||
"lanzaboote": "lanzaboote",
|
"lanzaboote": "lanzaboote",
|
||||||
"nix_builder": "nix_builder",
|
"nix_builder": "nix_builder",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs"
|
||||||
"nixpkgs-google": "nixpkgs-google"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-overlay": {
|
"rust-overlay": {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
nixpkgs-google.url = "github:NixOS/nixpkgs/45f6cfaa4605b706c870e75bd74bdb5e97eee11e";
|
|
||||||
lanzaboote = {
|
lanzaboote = {
|
||||||
url = "github:nix-community/lanzaboote/v0.4.2";
|
url = "github:nix-community/lanzaboote/v0.4.2";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
@@ -39,7 +38,6 @@
|
|||||||
{
|
{
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
nixpkgs-google,
|
|
||||||
disko,
|
disko,
|
||||||
impermanence,
|
impermanence,
|
||||||
lanzaboote,
|
lanzaboote,
|
||||||
@@ -99,9 +97,6 @@
|
|||||||
hostPlatform.gcc.arch = "default";
|
hostPlatform.gcc.arch = "default";
|
||||||
hostPlatform.gcc.tune = "default";
|
hostPlatform.gcc.tune = "default";
|
||||||
};
|
};
|
||||||
google = import nixpkgs-google {
|
|
||||||
system = prev.stdenv.hostPlatform.system;
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
additional_config = {
|
additional_config = {
|
||||||
speedFactor = 2;
|
speedFactor = 2;
|
||||||
};
|
};
|
||||||
|
substituter_url = "ssh-ng://nixworker@ns1.fizz.buzz:65122?compress=true&ssh-key=/persist/manual/ssh/root/keys/id_ed25519&remote-store=local?root=/.disk/root";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,8 @@
|
|||||||
# systemd.user.extraConfig = "DefaultLimitNOFILE=8192";
|
# systemd.user.extraConfig = "DefaultLimitNOFILE=8192";
|
||||||
# systemd.services."user@11400".serviceConfig.LimitNOFILE = "8192";
|
# systemd.services."user@11400".serviceConfig.LimitNOFILE = "8192";
|
||||||
|
|
||||||
|
nix.settings.secret-key-files = [ "/persist/manual/nix/nix-cache-key.sec" ];
|
||||||
|
|
||||||
me.build_in_ram.enable = true;
|
me.build_in_ram.enable = true;
|
||||||
me.dont_use_substituters.enable = true;
|
me.dont_use_substituters.enable = true;
|
||||||
me.hydra.enable = true;
|
me.hydra.enable = true;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
additional_config = {
|
additional_config = {
|
||||||
speedFactor = 2;
|
speedFactor = 2;
|
||||||
};
|
};
|
||||||
|
substituter_url = "ssh-ng://nixworker@ns1.fizz.buzz:65122?compress=true&ssh-key=/persist/manual/ssh/root/keys/id_ed25519&remote-store=local?root=/.disk/root";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
additional_config = {
|
additional_config = {
|
||||||
speedFactor = 2;
|
speedFactor = 2;
|
||||||
};
|
};
|
||||||
|
substituter_url = "ssh-ng://nixworker@ns1.fizz.buzz:65122?compress=true&ssh-key=/persist/manual/ssh/root/keys/id_ed25519&remote-store=local?root=/.disk/root";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
additional_config = {
|
additional_config = {
|
||||||
speedFactor = 2;
|
speedFactor = 2;
|
||||||
};
|
};
|
||||||
|
substituter_url = "ssh-ng://nixworker@ns1.fizz.buzz:65122?compress=true&ssh-key=/persist/manual/ssh/root/keys/id_ed25519&remote-store=local?root=/.disk/root";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,25 +59,16 @@ let
|
|||||||
hostName = lib.mkForce "hydra?remote-store=local?root=/.disk/root";
|
hostName = lib.mkForce "hydra?remote-store=local?root=/.disk/root";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
joined_configs =
|
substituters_list = (
|
||||||
lib.genAttrs
|
map (
|
||||||
(builtins.filter (hostname: config.me.distributed_build.machines."${hostname}".enable) (
|
hostname:
|
||||||
builtins.attrNames all_nixos_configs
|
(lib.mkIf (
|
||||||
))
|
config.me.distributed_build.machines."${hostname}".enable
|
||||||
(
|
&& config.me.distributed_build.machines."${hostname}".substituter_url != null
|
||||||
hostname:
|
) (config.me.distributed_build.machines."${hostname}".substituter_url))
|
||||||
(lib.mkMerge [
|
) (builtins.attrNames all_nixos_configs)
|
||||||
{
|
);
|
||||||
hostName = hostname;
|
has_any_substituters = substituters_list != [ ];
|
||||||
sshUser = "nixworker";
|
|
||||||
sshKey = "/persist/manual/ssh/root/keys/id_ed25519";
|
|
||||||
maxJobs = 1;
|
|
||||||
supportedFeatures = all_nixos_configs."${hostname}".config.me.optimizations.system_features;
|
|
||||||
}
|
|
||||||
static_host_configs."${hostname}"
|
|
||||||
config.me.distributed_build.machines."${hostname}".additional_config
|
|
||||||
])
|
|
||||||
);
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ ];
|
imports = [ ];
|
||||||
@@ -117,6 +108,7 @@ in
|
|||||||
"odo:0S/XKSFjjIrihQ7lbHEIebXk/c/xuoodhm0Gz26YhjA="
|
"odo:0S/XKSFjjIrihQ7lbHEIebXk/c/xuoodhm0Gz26YhjA="
|
||||||
"odowork:zg3UKBAyLy3xtZkL0hMtbxHjxgn5A2QY8NNAgyRT6Yo="
|
"odowork:zg3UKBAyLy3xtZkL0hMtbxHjxgn5A2QY8NNAgyRT6Yo="
|
||||||
"quark:Eb6ygkIiVlcUqb5hOjEVIQcfYLpCz40YVYA3/rxrgBc="
|
"quark:Eb6ygkIiVlcUqb5hOjEVIQcfYLpCz40YVYA3/rxrgBc="
|
||||||
|
"hydra:1s4Cy9YJLgw4jWx5jdSCfJmIm0hfya7WEy/EwJYI5Ys="
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -140,12 +132,10 @@ in
|
|||||||
) (builtins.attrNames all_nixos_configs)
|
) (builtins.attrNames all_nixos_configs)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
# {
|
(lib.mkIf has_any_substituters {
|
||||||
# nix.settings.substitute = lib.mkForce true;
|
nix.settings.substitute = lib.mkForce true;
|
||||||
# nix.settings.substituters = lib.mkForce (
|
nix.settings.substituters = lib.mkForce substituters_list;
|
||||||
# lib.mapAttrsToList (hostname: joined_config: "ssh-ng://${joined_config.hostName}") joined_configs
|
})
|
||||||
# );
|
|
||||||
# }
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf config.me.gcloud.enable {
|
config = lib.mkIf config.me.gcloud.enable {
|
||||||
environment.systemPackages = with pkgs.google; [
|
environment.systemPackages = with pkgs; [
|
||||||
(google-cloud-sdk.withExtraComponents [ google-cloud-sdk.components.gke-gcloud-auth-plugin ])
|
(google-cloud-sdk.withExtraComponents [ google-cloud-sdk.components.gke-gcloud-auth-plugin ])
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,10 @@
|
|||||||
"worker2_update"
|
"worker2_update"
|
||||||
"family_disks"
|
"family_disks"
|
||||||
"family_disks_update"
|
"family_disks_update"
|
||||||
# "nixbsd" # Disabled due to onetbb tests hanging on one-cpu machines.
|
"nixbsd"
|
||||||
|
"nix_builder_develop"
|
||||||
|
"organic_develop"
|
||||||
|
"natter_develop"
|
||||||
];
|
];
|
||||||
build_flags = lib.concatMap (target: [
|
build_flags = lib.concatMap (target: [
|
||||||
"--target"
|
"--target"
|
||||||
|
|||||||
@@ -67,98 +67,98 @@ output_directory = "/home/nixworker/persist/nix_builder"
|
|||||||
[[targets]]
|
[[targets]]
|
||||||
name = "controller0"
|
name = "controller0"
|
||||||
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
||||||
branch = "kubernetes"
|
branch = "nix"
|
||||||
path = "nix/kubernetes"
|
path = "nix/kubernetes"
|
||||||
attr = "controller0.vm_iso"
|
attr = "controller0.vm_iso"
|
||||||
|
|
||||||
[[targets]]
|
[[targets]]
|
||||||
name = "controller0_update"
|
name = "controller0_update"
|
||||||
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
||||||
branch = "kubernetes"
|
branch = "nix"
|
||||||
path = "nix/kubernetes"
|
path = "nix/kubernetes"
|
||||||
attr = "controller0.vm_iso"
|
attr = "controller0.vm_iso"
|
||||||
update = true
|
update = true
|
||||||
update_branch = "kubernetes_update"
|
update_branch = "nix_update"
|
||||||
|
|
||||||
[[targets]]
|
[[targets]]
|
||||||
name = "controller1"
|
name = "controller1"
|
||||||
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
||||||
branch = "kubernetes"
|
branch = "nix"
|
||||||
path = "nix/kubernetes"
|
path = "nix/kubernetes"
|
||||||
attr = "controller1.vm_iso"
|
attr = "controller1.vm_iso"
|
||||||
|
|
||||||
[[targets]]
|
[[targets]]
|
||||||
name = "controller1_update"
|
name = "controller1_update"
|
||||||
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
||||||
branch = "kubernetes"
|
branch = "nix"
|
||||||
path = "nix/kubernetes"
|
path = "nix/kubernetes"
|
||||||
attr = "controller1.vm_iso"
|
attr = "controller1.vm_iso"
|
||||||
update = true
|
update = true
|
||||||
update_branch = "kubernetes_update"
|
update_branch = "nix_update"
|
||||||
|
|
||||||
[[targets]]
|
[[targets]]
|
||||||
name = "controller2"
|
name = "controller2"
|
||||||
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
||||||
branch = "kubernetes"
|
branch = "nix"
|
||||||
path = "nix/kubernetes"
|
path = "nix/kubernetes"
|
||||||
attr = "controller2.vm_iso"
|
attr = "controller2.vm_iso"
|
||||||
|
|
||||||
[[targets]]
|
[[targets]]
|
||||||
name = "controller2_update"
|
name = "controller2_update"
|
||||||
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
||||||
branch = "kubernetes"
|
branch = "nix"
|
||||||
path = "nix/kubernetes"
|
path = "nix/kubernetes"
|
||||||
attr = "controller2.vm_iso"
|
attr = "controller2.vm_iso"
|
||||||
update = true
|
update = true
|
||||||
update_branch = "kubernetes_update"
|
update_branch = "nix_update"
|
||||||
|
|
||||||
[[targets]]
|
[[targets]]
|
||||||
name = "worker0"
|
name = "worker0"
|
||||||
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
||||||
branch = "kubernetes"
|
branch = "nix"
|
||||||
path = "nix/kubernetes"
|
path = "nix/kubernetes"
|
||||||
attr = "worker0.vm_iso"
|
attr = "worker0.vm_iso"
|
||||||
|
|
||||||
[[targets]]
|
[[targets]]
|
||||||
name = "worker0_update"
|
name = "worker0_update"
|
||||||
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
||||||
branch = "kubernetes"
|
branch = "nix"
|
||||||
path = "nix/kubernetes"
|
path = "nix/kubernetes"
|
||||||
attr = "worker0.vm_iso"
|
attr = "worker0.vm_iso"
|
||||||
update = true
|
update = true
|
||||||
update_branch = "kubernetes_update"
|
update_branch = "nix_update"
|
||||||
|
|
||||||
[[targets]]
|
[[targets]]
|
||||||
name = "worker1"
|
name = "worker1"
|
||||||
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
||||||
branch = "kubernetes"
|
branch = "nix"
|
||||||
path = "nix/kubernetes"
|
path = "nix/kubernetes"
|
||||||
attr = "worker1.vm_iso"
|
attr = "worker1.vm_iso"
|
||||||
|
|
||||||
[[targets]]
|
[[targets]]
|
||||||
name = "worker1_update"
|
name = "worker1_update"
|
||||||
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
||||||
branch = "kubernetes"
|
branch = "nix"
|
||||||
path = "nix/kubernetes"
|
path = "nix/kubernetes"
|
||||||
attr = "worker1.vm_iso"
|
attr = "worker1.vm_iso"
|
||||||
update = true
|
update = true
|
||||||
update_branch = "kubernetes_update"
|
update_branch = "nix_update"
|
||||||
|
|
||||||
[[targets]]
|
[[targets]]
|
||||||
name = "worker2"
|
name = "worker2"
|
||||||
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
||||||
branch = "kubernetes"
|
branch = "nix"
|
||||||
path = "nix/kubernetes"
|
path = "nix/kubernetes"
|
||||||
attr = "worker2.vm_iso"
|
attr = "worker2.vm_iso"
|
||||||
|
|
||||||
[[targets]]
|
[[targets]]
|
||||||
name = "worker2_update"
|
name = "worker2_update"
|
||||||
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
|
||||||
branch = "kubernetes"
|
branch = "nix"
|
||||||
path = "nix/kubernetes"
|
path = "nix/kubernetes"
|
||||||
attr = "worker2.vm_iso"
|
attr = "worker2.vm_iso"
|
||||||
update = true
|
update = true
|
||||||
update_branch = "kubernetes_update"
|
update_branch = "nix_update"
|
||||||
|
|
||||||
# TODO: Add steam deck
|
# TODO: Add steam deck
|
||||||
|
|
||||||
@@ -178,9 +178,30 @@ output_directory = "/home/nixworker/persist/nix_builder"
|
|||||||
update = true
|
update = true
|
||||||
update_branch = "nix_update"
|
update_branch = "nix_update"
|
||||||
|
|
||||||
# [[targets]]
|
[[targets]]
|
||||||
# name = "nixbsd"
|
name = "nixbsd"
|
||||||
# repo = "https://github.com/nixos-bsd/nixbsd.git"
|
repo = "https://github.com/nixos-bsd/nixbsd.git"
|
||||||
# revision = "828ff7a3c4ee91f548de65a963fca40eaedb171c"
|
revision = "2b512eda58e6d77378bd20d6027802b158942e24"
|
||||||
# path = "."
|
path = "."
|
||||||
# attr = "base.vmClosureInfo"
|
attr = "base.vmClosureInfo"
|
||||||
|
|
||||||
|
[[targets]]
|
||||||
|
name = "nix_builder_develop"
|
||||||
|
repo = "https://code.fizz.buzz/talexander/nix_builder.git"
|
||||||
|
branch = "main"
|
||||||
|
path = "."
|
||||||
|
attr = "devShells.x86_64-linux.default"
|
||||||
|
|
||||||
|
[[targets]]
|
||||||
|
name = "organic_develop"
|
||||||
|
repo = "https://code.fizz.buzz/talexander/organic.git"
|
||||||
|
branch = "main"
|
||||||
|
path = "."
|
||||||
|
attr = "devShells.x86_64-linux.default"
|
||||||
|
|
||||||
|
[[targets]]
|
||||||
|
name = "natter_develop"
|
||||||
|
repo = "https://code.fizz.buzz/talexander/natter.git"
|
||||||
|
branch = "main"
|
||||||
|
path = "."
|
||||||
|
attr = "devShells.x86_64-linux.default"
|
||||||
|
|||||||
@@ -25,8 +25,8 @@
|
|||||||
nixpkgs.overlays = [
|
nixpkgs.overlays = [
|
||||||
(final: prev: {
|
(final: prev: {
|
||||||
tex = (
|
tex = (
|
||||||
pkgs.texlive.combine {
|
pkgs.texliveSmall.withPackages (
|
||||||
inherit (pkgs.texlive)
|
ps: with ps; [
|
||||||
scheme-basic
|
scheme-basic
|
||||||
dvisvgm
|
dvisvgm
|
||||||
dvipng # for preview and export as html in org-mode
|
dvipng # for preview and export as html in org-mode
|
||||||
@@ -44,8 +44,8 @@
|
|||||||
upquote # emacs org-mode pdf export
|
upquote # emacs org-mode pdf export
|
||||||
lineno # emacs org-mode pdf export
|
lineno # emacs org-mode pdf export
|
||||||
beamer # emacs org-mode presentation pdf export
|
beamer # emacs org-mode presentation pdf export
|
||||||
;
|
]
|
||||||
}
|
)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ in
|
|||||||
# TODO: The 127.0.0.1 address should probably be moved to a host-specific file.
|
# TODO: The 127.0.0.1 address should probably be moved to a host-specific file.
|
||||||
networking.extraHosts = ''
|
networking.extraHosts = ''
|
||||||
127.0.0.1 ${config.networking.hostName}.home.arpa
|
127.0.0.1 ${config.networking.hostName}.home.arpa
|
||||||
|
127.0.0.3 metadata.google.internal
|
||||||
10.216.1.32 homeserver
|
10.216.1.32 homeserver
|
||||||
fdfd:5e8a:ee2d::1:32 homeserver
|
fdfd:5e8a:ee2d::1:32 homeserver
|
||||||
10.216.1.6 media
|
10.216.1.6 media
|
||||||
@@ -67,7 +68,15 @@ in
|
|||||||
10.217.1.1 drmario
|
10.217.1.1 drmario
|
||||||
10.217.2.1 mrmanager
|
10.217.2.1 mrmanager
|
||||||
fdfd:5e8a:ee2d::2:2 mrmanager
|
fdfd:5e8a:ee2d::2:2 mrmanager
|
||||||
|
172.16.16.1 unifi
|
||||||
|
172.16.16.231 plug1
|
||||||
|
172.16.16.232 plug2
|
||||||
|
172.16.16.233 plug3
|
||||||
|
172.16.16.234 plug4
|
||||||
|
172.16.16.235 temperature1
|
||||||
|
172.16.16.236 temperature2
|
||||||
172.16.16.245 turtle
|
172.16.16.245 turtle
|
||||||
|
172.16.16.250 sauna
|
||||||
172.16.16.251 stream
|
172.16.16.251 stream
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,23 @@
|
|||||||
DOCKER_HOST = "unix://$XDG_RUNTIME_DIR/podman/podman.sock";
|
DOCKER_HOST = "unix://$XDG_RUNTIME_DIR/podman/podman.sock";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Increase subuid / subgid to support running buildkit-rootless
|
||||||
|
# ref: https://github.com/moby/buildkit/issues/3297
|
||||||
|
users.users.talexander = {
|
||||||
|
subUidRanges = [
|
||||||
|
{
|
||||||
|
startUid = 100000;
|
||||||
|
count = 262144; # default = 65536
|
||||||
|
}
|
||||||
|
];
|
||||||
|
subGidRanges = [
|
||||||
|
{
|
||||||
|
startGid = 100000;
|
||||||
|
count = 262144; # default = 65536
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
environment.persistence."/state" = lib.mkIf (config.me.mountPersistence) {
|
environment.persistence."/state" = lib.mkIf (config.me.mountPersistence) {
|
||||||
hideMounts = true;
|
hideMounts = true;
|
||||||
directories = [
|
directories = [
|
||||||
|
|||||||
@@ -20,8 +20,9 @@
|
|||||||
config = lib.mkIf (config.me.wine.enable && config.me.graphical) {
|
config = lib.mkIf (config.me.wine.enable && config.me.graphical) {
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
# wineWowPackages.stable # supports 32 + 64 bit
|
# wineWowPackages.stable # supports 32 + 64 bit
|
||||||
wineWowPackages.waylandFull # Supports 32 + 64 bit with native wayland support.
|
wineWow64Packages.waylandFull # Supports 32 + 64 bit with native wayland support.
|
||||||
# winetricks
|
# winetricks
|
||||||
|
# lutris
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
1
nix/kubernetes/.gitignore
vendored
Normal file
1
nix/kubernetes/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
result
|
||||||
132
nix/kubernetes/README.org
Normal file
132
nix/kubernetes/README.org
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
* To-do
|
||||||
|
** Perhaps use overlay for /etc for speedup
|
||||||
|
#+begin_src nix
|
||||||
|
system.etc.overlay.enable = true;
|
||||||
|
#+end_src
|
||||||
|
** read https://nixos.org/manual/nixos/stable/
|
||||||
|
** Performance for mini pc
|
||||||
|
#+begin_src nix
|
||||||
|
security.pam.loginLimits = [
|
||||||
|
{ domain = "@users"; item = "rtprio"; type = "-"; value = 1; }
|
||||||
|
];
|
||||||
|
#+end_src
|
||||||
|
* IP Ranges
|
||||||
|
| | IPv4 | IPv6 |
|
||||||
|
|--------------------------------+-----------------------------+-----------------------------------------|
|
||||||
|
| Pod | 10.200.0.0/16 | 2620:11f:7001:7:ffff:eeee::/96 |
|
||||||
|
| Service | 10.197.0.0/16 | fd00:3e42:e349::/112 |
|
||||||
|
| Node | 10.215.1.0/24 | 2620:11f:7001:7:ffff:ffff:0ad7:0100/120 |
|
||||||
|
| Load Balancer | 74.80.180.139-74.80.180.142 | 2620:11f:7001:7:ffff:dddd::/96 |
|
||||||
|
| Load Balancer Private (unused) | 10.198.0.0/16 | fd9c:0bd5:22a4::/112 |
|
||||||
|
| PowerDNS from inside cluster | 10.215.1.211 | |
|
||||||
|
* Healthcheck
|
||||||
|
** Check cilium status
|
||||||
|
#+begin_src bash
|
||||||
|
kubectl -n kube-system exec ds/cilium -- cilium-dbg status --verbose
|
||||||
|
kubectl -n kube-system exec ds/cilium -- cilium-dbg status | grep KubeProxyReplacement
|
||||||
|
#+end_src
|
||||||
|
** Check connectivity
|
||||||
|
#+begin_src bash
|
||||||
|
cilium connectivity test
|
||||||
|
#+end_src
|
||||||
|
** Show dropped packets
|
||||||
|
#+begin_src bash
|
||||||
|
kubectl -n kube-system exec ds/cilium -- cilium-dbg monitor --type drop
|
||||||
|
#+end_src
|
||||||
|
** Show dropped packets for a specific pod
|
||||||
|
#+begin_src bash
|
||||||
|
kubectl -n kube-system exec ds/cilium -- hubble observe --since 30s --pod cnpg-system/cnpg-controller-manager-84d498b97-q5m4n --type drop
|
||||||
|
#+end_src
|
||||||
|
** Install flux
|
||||||
|
#+begin_src bash
|
||||||
|
nix shell 'nixpkgs#fluxcd'
|
||||||
|
|
||||||
|
flux bootstrap git \
|
||||||
|
--url=ssh://git@<host>/<org>/<repository> \
|
||||||
|
--branch=main \
|
||||||
|
--private-key-file=<path/to/private.key> \
|
||||||
|
--password=<key-passphrase> \
|
||||||
|
--path=clusters/my-cluster
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src bash
|
||||||
|
nix shell 'nixpkgs#kubernetes-helm'
|
||||||
|
|
||||||
|
helm template --dry-run=server flux-operator oci://ghcr.io/controlplaneio-fluxcd/charts/flux-operator \
|
||||||
|
--namespace flux-system \
|
||||||
|
--create-namespace
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src text
|
||||||
|
apiVersion: fluxcd.controlplane.io/v1
|
||||||
|
kind: FluxInstance
|
||||||
|
metadata:
|
||||||
|
name: flux
|
||||||
|
namespace: flux-system
|
||||||
|
annotations:
|
||||||
|
fluxcd.controlplane.io/reconcileEvery: "1h"
|
||||||
|
fluxcd.controlplane.io/reconcileTimeout: "5m"
|
||||||
|
spec:
|
||||||
|
distribution:
|
||||||
|
version: "2.x"
|
||||||
|
registry: "ghcr.io/fluxcd"
|
||||||
|
artifact: "oci://ghcr.io/controlplaneio-fluxcd/flux-operator-manifests"
|
||||||
|
components:
|
||||||
|
- source-controller
|
||||||
|
- kustomize-controller
|
||||||
|
- helm-controller
|
||||||
|
- notification-controller
|
||||||
|
- image-reflector-controller
|
||||||
|
- image-automation-controller
|
||||||
|
cluster:
|
||||||
|
type: kubernetes
|
||||||
|
size: medium
|
||||||
|
multitenant: false
|
||||||
|
networkPolicy: true
|
||||||
|
domain: "cluster.local"
|
||||||
|
kustomize:
|
||||||
|
patches:
|
||||||
|
- target:
|
||||||
|
kind: Deployment
|
||||||
|
patch: |
|
||||||
|
- op: replace
|
||||||
|
path: /spec/template/spec/nodeSelector
|
||||||
|
value:
|
||||||
|
kubernetes.io/os: linux
|
||||||
|
- op: add
|
||||||
|
path: /spec/template/spec/tolerations
|
||||||
|
value:
|
||||||
|
- key: "CriticalAddonsOnly"
|
||||||
|
operator: "Exists"
|
||||||
|
sync:
|
||||||
|
kind: OCIRepository
|
||||||
|
url: "oci://ghcr.io/my-org/my-fleet-manifests"
|
||||||
|
ref: "latest"
|
||||||
|
path: "clusters/my-cluster"
|
||||||
|
pullSecret: "ghcr-auth"
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src text
|
||||||
|
apiVersion: fluxcd.controlplane.io/v1
|
||||||
|
kind: FluxInstance
|
||||||
|
metadata:
|
||||||
|
name: flux
|
||||||
|
namespace: flux-system
|
||||||
|
spec:
|
||||||
|
distribution:
|
||||||
|
version: "2.7.x"
|
||||||
|
registry: "ghcr.io/fluxcd"
|
||||||
|
sync:
|
||||||
|
kind: GitRepository
|
||||||
|
url: "ssh://git@10.215.1.210:22/repos/mrmanager"
|
||||||
|
ref: "refs/heads/nix"
|
||||||
|
path: "clusters/my-cluster"
|
||||||
|
pullSecret: "flux-system"
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
#+begin_src bash
|
||||||
|
flux create secret git flux-system \
|
||||||
|
--url=https://gitlab.com/my-org/my-fleet.git \
|
||||||
|
--username=git \
|
||||||
|
--password=$GITLAB_TOKEN
|
||||||
|
#+end_src
|
||||||
149
nix/kubernetes/configuration.nix
Normal file
149
nix/kubernetes/configuration.nix
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./roles/boot
|
||||||
|
./roles/cilium
|
||||||
|
./roles/containerd
|
||||||
|
./roles/control_plane
|
||||||
|
./roles/debugging
|
||||||
|
./roles/doas
|
||||||
|
./roles/dont_use_substituters
|
||||||
|
./roles/etcd
|
||||||
|
./roles/firewall
|
||||||
|
./roles/image_based_appliance
|
||||||
|
./roles/iso
|
||||||
|
./roles/kernel
|
||||||
|
./roles/kube_apiserver
|
||||||
|
./roles/kube_controller_manager
|
||||||
|
./roles/kube_proxy
|
||||||
|
./roles/kube_scheduler
|
||||||
|
./roles/kubelet
|
||||||
|
./roles/kubernetes
|
||||||
|
./roles/minimal_base
|
||||||
|
./roles/network
|
||||||
|
./roles/nvme
|
||||||
|
./roles/optimized_build
|
||||||
|
./roles/ssh
|
||||||
|
./roles/sshd
|
||||||
|
./roles/user
|
||||||
|
./roles/worker_node
|
||||||
|
./roles/zsh
|
||||||
|
./util/install_files
|
||||||
|
./util/unfree_polyfill
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
nix.settings.experimental-features = [
|
||||||
|
"nix-command"
|
||||||
|
"flakes"
|
||||||
|
"ca-derivations"
|
||||||
|
# "blake3-hashes"
|
||||||
|
# "git-hashing"
|
||||||
|
];
|
||||||
|
nix.settings.trusted-users = [ "@wheel" ];
|
||||||
|
|
||||||
|
hardware.enableRedistributableFirmware = true;
|
||||||
|
|
||||||
|
# Keep outputs so we can build offline.
|
||||||
|
nix.settings.keep-outputs = true;
|
||||||
|
nix.settings.keep-derivations = true;
|
||||||
|
|
||||||
|
# Automatic garbage collection
|
||||||
|
nix.gc = lib.mkIf (!config.me.buildingPortable) {
|
||||||
|
# Runs nix-collect-garbage --delete-older-than 5d
|
||||||
|
automatic = true;
|
||||||
|
persistent = true;
|
||||||
|
dates = "monthly";
|
||||||
|
# randomizedDelaySec = "14m";
|
||||||
|
options = "--delete-older-than 30d";
|
||||||
|
};
|
||||||
|
nix.settings.auto-optimise-store = !config.me.buildingPortable;
|
||||||
|
|
||||||
|
environment.persistence."/persist" = lib.mkIf (config.me.mountPersistence) {
|
||||||
|
hideMounts = true;
|
||||||
|
directories = [
|
||||||
|
"/var/lib/nixos" # Contains user information (uids/gids)
|
||||||
|
"/var/lib/systemd" # Systemd state directory for random seed, persistent timers, core dumps, persist hardware state like backlight and rfkill
|
||||||
|
"/var/log/journal" # Logs, alternatively set `services.journald.storage = "volatile";` to write to /run/log/journal
|
||||||
|
];
|
||||||
|
files = [
|
||||||
|
"/etc/machine-id" # Systemd unique machine id "otherwise, the system journal may fail to list earlier boots, etc"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Write a list of the currently installed packages to /etc/current-system-packages
|
||||||
|
# environment.etc."current-system-packages".text =
|
||||||
|
# let
|
||||||
|
# packages = builtins.map (p: "${p.name}") config.environment.systemPackages;
|
||||||
|
# sortedUnique = builtins.sort builtins.lessThan (lib.unique packages);
|
||||||
|
# formatted = builtins.concatStringsSep "\n" sortedUnique;
|
||||||
|
# in
|
||||||
|
# formatted;
|
||||||
|
|
||||||
|
# nixpkgs.overlays = [
|
||||||
|
# (final: prev: {
|
||||||
|
# foot = throw "foo";
|
||||||
|
# })
|
||||||
|
# ];
|
||||||
|
|
||||||
|
nixpkgs.overlays =
|
||||||
|
let
|
||||||
|
disableTests = (
|
||||||
|
package_name:
|
||||||
|
(final: prev: {
|
||||||
|
"${package_name}" = prev."${package_name}".overrideAttrs (old: {
|
||||||
|
doCheck = false;
|
||||||
|
doInstallCheck = false;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
in
|
||||||
|
[
|
||||||
|
# (final: prev: {
|
||||||
|
# imagemagick = prev.imagemagick.overrideAttrs (old: rec {
|
||||||
|
# # 7.1.2-6 seems to no longer exist, so use 7.1.2-7
|
||||||
|
# version = "7.1.2-7";
|
||||||
|
|
||||||
|
# src = final.fetchFromGitHub {
|
||||||
|
# owner = "ImageMagick";
|
||||||
|
# repo = "ImageMagick";
|
||||||
|
# tag = version;
|
||||||
|
# hash = "sha256-9ARCYftoXiilpJoj+Y+aLCEqLmhHFYSrHfgA5DQHbGo=";
|
||||||
|
# };
|
||||||
|
# });
|
||||||
|
# })
|
||||||
|
# (final: prev: {
|
||||||
|
# grub2 = (final.callPackage ./package/grub { });
|
||||||
|
# })
|
||||||
|
(final: prev: {
|
||||||
|
inherit (final.unoptimized)
|
||||||
|
libtpms
|
||||||
|
;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
# This option defines the first version of NixOS you have installed on this particular machine,
|
||||||
|
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
|
||||||
|
#
|
||||||
|
# Most users should NEVER change this value after the initial install, for any reason,
|
||||||
|
# even if you've upgraded your system to a new NixOS release.
|
||||||
|
#
|
||||||
|
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
|
||||||
|
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
|
||||||
|
# to actually do that.
|
||||||
|
#
|
||||||
|
# This value being lower than the current NixOS release does NOT mean your system is
|
||||||
|
# out of date, out of support, or vulnerable.
|
||||||
|
#
|
||||||
|
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
|
||||||
|
# and migrated your data accordingly.
|
||||||
|
#
|
||||||
|
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
|
||||||
|
system.stateVersion = "24.11"; # Did you read the comment?
|
||||||
|
};
|
||||||
|
}
|
||||||
256
nix/kubernetes/flake.lock
generated
Normal file
256
nix/kubernetes/flake.lock
generated
Normal file
@@ -0,0 +1,256 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"crane": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731098351,
|
||||||
|
"narHash": "sha256-HQkYvKvaLQqNa10KEFGgWHfMAbWBfFp+4cAgkut+NNE=",
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"rev": "ef80ead953c1b28316cc3f8613904edc2eb90c28",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"disko": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1781152676,
|
||||||
|
"narHash": "sha256-RxWs5ND31KzTG7wvMM+PMfUjyNpmIEr999lqNARaM5o=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "disko",
|
||||||
|
"rev": "ff8702b4de27f72b4c78573dfb89ec74e36abdf1",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "disko",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-compat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1696426674,
|
||||||
|
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": [
|
||||||
|
"lanzaboote",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1730504689,
|
||||||
|
"narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "506278e768c2a08bec68eb62932193e341f55c90",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gitignore": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"lanzaboote",
|
||||||
|
"pre-commit-hooks-nix",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1709087332,
|
||||||
|
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"home-manager": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"impermanence",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1768598210,
|
||||||
|
"narHash": "sha256-kkgA32s/f4jaa4UG+2f8C225Qvclxnqs76mf8zvTVPg=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"rev": "c47b2cc64a629f8e075de52e4742de688f930dc6",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"impermanence": {
|
||||||
|
"inputs": {
|
||||||
|
"home-manager": "home-manager",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1769548169,
|
||||||
|
"narHash": "sha256-03+JxvzmfwRu+5JafM0DLbxgHttOQZkUtDWBmeUkN8Y=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "impermanence",
|
||||||
|
"rev": "7b1d382faf603b6d264f58627330f9faa5cba149",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "impermanence",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lanzaboote": {
|
||||||
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"pre-commit-hooks-nix": "pre-commit-hooks-nix",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1737639419,
|
||||||
|
"narHash": "sha256-AEEDktApTEZ5PZXNDkry2YV2k6t0dTgLPEmAZbnigXU=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "lanzaboote",
|
||||||
|
"rev": "a65905a09e2c43ff63be8c0e86a93712361f871e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"ref": "v0.4.2",
|
||||||
|
"repo": "lanzaboote",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1784120854,
|
||||||
|
"narHash": "sha256-KesHgItiZPgGX740axSiQLcIQ8D24MDqNpkKYWIek8k=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "753cc8a3a87467296ddd1fa93f0cc3e81120ee46",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-stable": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1730741070,
|
||||||
|
"narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "d063c1dd113c91ab27959ba540c0d9753409edf3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-24.05",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pre-commit-hooks-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": [
|
||||||
|
"lanzaboote",
|
||||||
|
"flake-compat"
|
||||||
|
],
|
||||||
|
"gitignore": "gitignore",
|
||||||
|
"nixpkgs": [
|
||||||
|
"lanzaboote",
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"nixpkgs-stable": "nixpkgs-stable"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731363552,
|
||||||
|
"narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "pre-commit-hooks.nix",
|
||||||
|
"rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "pre-commit-hooks.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"disko": "disko",
|
||||||
|
"impermanence": "impermanence",
|
||||||
|
"lanzaboote": "lanzaboote",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"lanzaboote",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731897198,
|
||||||
|
"narHash": "sha256-Ou7vLETSKwmE/HRQz4cImXXJBr/k9gp4J4z/PF8LzTE=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "0be641045af6d8666c11c2c40e45ffc9667839b5",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
183
nix/kubernetes/flake.nix
Normal file
183
nix/kubernetes/flake.nix
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
# Get a repl for this flake
|
||||||
|
# nix repl --expr "builtins.getFlake \"$PWD\""
|
||||||
|
|
||||||
|
# TODO maybe use `nix eval --raw .#odo.iso.outPath`
|
||||||
|
|
||||||
|
#
|
||||||
|
# Install on a new machine:
|
||||||
|
#
|
||||||
|
# Set
|
||||||
|
# me.disko.enable = true;
|
||||||
|
# me.disko.offline.enable = true;
|
||||||
|
#
|
||||||
|
# Run
|
||||||
|
# doas disko --mode destroy,format,mount hosts/recovery/disk-config.nix
|
||||||
|
# doas nixos-install --substituters "http://10.0.2.2:8080?trusted=1 https://cache.nixos.org/" --flake ".#recovery"
|
||||||
|
|
||||||
|
{
|
||||||
|
description = "My system configuration";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
impermanence = {
|
||||||
|
url = "github:nix-community/impermanence";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
lanzaboote = {
|
||||||
|
url = "github:nix-community/lanzaboote/v0.4.2";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
disko = {
|
||||||
|
url = "github:nix-community/disko";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
disko,
|
||||||
|
impermanence,
|
||||||
|
lanzaboote,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
forAllSystems =
|
||||||
|
func:
|
||||||
|
builtins.listToAttrs (
|
||||||
|
map (system: {
|
||||||
|
name = system;
|
||||||
|
value = func system;
|
||||||
|
}) nixpkgs.lib.systems.flakeExposed
|
||||||
|
);
|
||||||
|
nodes = {
|
||||||
|
controller0 = {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
};
|
||||||
|
controller1 = {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
};
|
||||||
|
controller2 = {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
};
|
||||||
|
worker0 = {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
};
|
||||||
|
worker1 = {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
};
|
||||||
|
worker2 = {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
nixosConfigs = builtins.mapAttrs (
|
||||||
|
hostname: nodeConfig: format:
|
||||||
|
nixpkgs.lib.nixosSystem {
|
||||||
|
specialArgs = {
|
||||||
|
inherit self;
|
||||||
|
|
||||||
|
this_nixos_config = self.nixosConfigurations."${hostname}";
|
||||||
|
|
||||||
|
all_nixos_configs = self.nixosConfigurations;
|
||||||
|
};
|
||||||
|
modules = [
|
||||||
|
impermanence.nixosModules.impermanence
|
||||||
|
lanzaboote.nixosModules.lanzaboote
|
||||||
|
disko.nixosModules.disko
|
||||||
|
./configuration.nix
|
||||||
|
(./. + "/hosts/${hostname}")
|
||||||
|
(./. + "/formats/${format}.nix")
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
nixpkgs.hostPlatform.system = nodeConfig.system;
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: prev: {
|
||||||
|
# stable = nixpkgs-stable.legacyPackages."${prev.stdenv.hostPlatform.system}";
|
||||||
|
unoptimized = import nixpkgs {
|
||||||
|
system = prev.stdenv.hostPlatform.system;
|
||||||
|
hostPlatform.gcc.arch = "default";
|
||||||
|
hostPlatform.gcc.tune = "default";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
nix-self-repl = pkgs.writeShellScriptBin "nix-self-repl" ''
|
||||||
|
source /etc/set-environment
|
||||||
|
nix repl --expr 'builtins.getFlake "${self}"'
|
||||||
|
'';
|
||||||
|
# If we wanted the current version of a flake then we'd just launch
|
||||||
|
# nix repl
|
||||||
|
# and then run:
|
||||||
|
# :lf /path/to/flake
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
environment.systemPackages = lib.mkIf config.nix.enable [ nix-self-repl ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
) nodes;
|
||||||
|
installerConfig =
|
||||||
|
hostname: nodeConfig:
|
||||||
|
nixpkgs.lib.nixosSystem {
|
||||||
|
specialArgs = {
|
||||||
|
targetSystem = self.nixosConfigurations."${hostname}";
|
||||||
|
};
|
||||||
|
modules = [
|
||||||
|
./formats/installer.nix
|
||||||
|
(
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
nix-self-repl = pkgs.writeShellScriptBin "nix-self-repl" ''
|
||||||
|
source /etc/set-environment
|
||||||
|
nix repl --expr 'builtins.getFlake "${self}"'
|
||||||
|
'';
|
||||||
|
# If we wanted the current version of a flake then we'd just launch
|
||||||
|
# nix repl
|
||||||
|
# and then run:
|
||||||
|
# :lf /path/to/flake
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
environment.systemPackages = lib.mkIf config.nix.enable [ nix-self-repl ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
({ nixpkgs.hostPlatform.system = nodeConfig.system; })
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
nixosConfigurations = (builtins.mapAttrs (name: value: value "toplevel") nixosConfigs);
|
||||||
|
}
|
||||||
|
// {
|
||||||
|
packages = (
|
||||||
|
forAllSystems (
|
||||||
|
system:
|
||||||
|
(builtins.mapAttrs (hostname: nodeConfig: {
|
||||||
|
iso = (nixosConfigs."${hostname}" "iso").config.system.build.isoImage;
|
||||||
|
vm_iso = (nixosConfigs."${hostname}" "vm_iso").config.system.build.isoImage;
|
||||||
|
sd = (nixosConfigs."${hostname}" "sd").config.system.build.sdImage;
|
||||||
|
installer = (installerConfig hostname nodes."${hostname}").config.system.build.isoImage;
|
||||||
|
}) (nixpkgs.lib.attrsets.filterAttrs (hostname: nodeConfig: nodeConfig.system == system) nodes))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
74
nix/kubernetes/formats/installer.nix
Normal file
74
nix/kubernetes/formats/installer.nix
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
targetSystem,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
installer = pkgs.writeShellApplication {
|
||||||
|
name = "installer";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
# clevis
|
||||||
|
dosfstools
|
||||||
|
e2fsprogs
|
||||||
|
gawk
|
||||||
|
nixos-install-tools
|
||||||
|
util-linux
|
||||||
|
config.nix.package
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
${targetSystem.config.system.build.diskoScript}
|
||||||
|
|
||||||
|
nixos-install --no-channel-copy --no-root-password --option substituters "" --system ${targetSystem.config.system.build.toplevel}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
installerFailsafe = pkgs.writeShellScript "failsafe" ''
|
||||||
|
${lib.getExe installer} || echo "ERROR: Installation failure!"
|
||||||
|
sleep 3600
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
(modulesPath + "/installer/cd-dvd/iso-image.nix")
|
||||||
|
(modulesPath + "/profiles/all-hardware.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
# boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_6_17;
|
||||||
|
# boot.zfs.package = pkgs.zfs_unstable;
|
||||||
|
boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux;
|
||||||
|
boot.kernelParams = [
|
||||||
|
"quiet"
|
||||||
|
"systemd.unit=getty.target"
|
||||||
|
];
|
||||||
|
boot.supportedFilesystems.zfs = true;
|
||||||
|
boot.initrd.systemd.enable = true;
|
||||||
|
|
||||||
|
networking.hostId = "04581ecf";
|
||||||
|
|
||||||
|
isoImage.makeEfiBootable = true;
|
||||||
|
isoImage.makeUsbBootable = true;
|
||||||
|
isoImage.squashfsCompression = "zstd -Xcompression-level 15";
|
||||||
|
|
||||||
|
environment.systemPackages = [
|
||||||
|
installer
|
||||||
|
];
|
||||||
|
|
||||||
|
systemd.services."getty@tty1" = {
|
||||||
|
overrideStrategy = "asDropin";
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = [
|
||||||
|
""
|
||||||
|
installerFailsafe
|
||||||
|
];
|
||||||
|
Restart = "no";
|
||||||
|
StandardInput = "null";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# system.stateVersion = lib.mkDefault lib.trivial.release;
|
||||||
|
system.stateVersion = "24.11";
|
||||||
|
}
|
||||||
36
nix/kubernetes/formats/iso.nix
Normal file
36
nix/kubernetes/formats/iso.nix
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
(modulesPath + "/installer/cd-dvd/iso-image.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
isoImage.makeEfiBootable = true;
|
||||||
|
isoImage.makeUsbBootable = true;
|
||||||
|
|
||||||
|
networking.dhcpcd.enable = true;
|
||||||
|
networking.useDHCP = true;
|
||||||
|
|
||||||
|
me.buildingPortable = true;
|
||||||
|
me.disko.enable = true;
|
||||||
|
me.disko.offline.enable = true;
|
||||||
|
me.mountPersistence = lib.mkForce false;
|
||||||
|
# me.optimizations.enable = lib.mkForce false;
|
||||||
|
|
||||||
|
# Not doing image_based_appliance because this might be an install ISO, in which case we'd need nix to do the install.
|
||||||
|
# me.image_based_appliance.enable = true;
|
||||||
|
|
||||||
|
# TODO: Should I use this instead of doing a mkIf for the disk config?
|
||||||
|
# disko.enableConfig = false;
|
||||||
|
|
||||||
|
# Faster image generation for testing/development.
|
||||||
|
isoImage.squashfsCompression = "zstd -Xcompression-level 15";
|
||||||
|
};
|
||||||
|
}
|
||||||
32
nix/kubernetes/formats/sd.nix
Normal file
32
nix/kubernetes/formats/sd.nix
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
modulesPath,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
(modulesPath + "/installer/sd-card/sd-image.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
isoImage.makeEfiBootable = true;
|
||||||
|
isoImage.makeUsbBootable = true;
|
||||||
|
|
||||||
|
boot.loader.grub.enable = false;
|
||||||
|
boot.loader.generic-extlinux-compatible.enable = true;
|
||||||
|
|
||||||
|
# TODO: image based appliance?
|
||||||
|
|
||||||
|
# TODO: Maybe this?
|
||||||
|
# fileSystems = {
|
||||||
|
# "/" = {
|
||||||
|
# device = "/dev/disk/by-label/NIXOS_SD";
|
||||||
|
# fsType = "ext4";
|
||||||
|
# options = [
|
||||||
|
# "noatime"
|
||||||
|
# "norelatime"
|
||||||
|
# ];
|
||||||
|
# };
|
||||||
|
# };
|
||||||
|
};
|
||||||
|
}
|
||||||
1
nix/kubernetes/formats/toplevel.nix
Normal file
1
nix/kubernetes/formats/toplevel.nix
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{ }
|
||||||
22
nix/kubernetes/formats/vm_iso.nix
Normal file
22
nix/kubernetes/formats/vm_iso.nix
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
(modulesPath + "/installer/cd-dvd/iso-image.nix")
|
||||||
|
(modulesPath + "/profiles/qemu-guest.nix") # VirtIO kernel modules
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
isoImage.makeEfiBootable = true;
|
||||||
|
isoImage.makeUsbBootable = true;
|
||||||
|
|
||||||
|
networking.dhcpcd.enable = true;
|
||||||
|
networking.useDHCP = true;
|
||||||
|
|
||||||
|
me.image_based_appliance.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
24
nix/kubernetes/functions/to_yaml.nix
Normal file
24
nix/kubernetes/functions/to_yaml.nix
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
to_yaml_file =
|
||||||
|
file_name: contents:
|
||||||
|
let
|
||||||
|
settingsFormat = pkgs.formats.yaml { };
|
||||||
|
yaml_file = settingsFormat.generate file_name contents;
|
||||||
|
in
|
||||||
|
yaml_file;
|
||||||
|
to_yaml =
|
||||||
|
file_name: contents:
|
||||||
|
let
|
||||||
|
settingsFormat = pkgs.formats.yaml { };
|
||||||
|
yaml_file = settingsFormat.generate file_name contents;
|
||||||
|
yaml_content = builtins.readFile yaml_file;
|
||||||
|
in
|
||||||
|
yaml_content;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit to_yaml to_yaml_file;
|
||||||
|
}
|
||||||
13
nix/kubernetes/hosts/controller0/DEPLOY_BOOT
Executable file
13
nix/kubernetes/hosts/controller0/DEPLOY_BOOT
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
TARGET=controller0
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
|
||||||
|
nixos-rebuild boot --flake "$DIR/../../#controller0" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
13
nix/kubernetes/hosts/controller0/DEPLOY_SWITCH
Executable file
13
nix/kubernetes/hosts/controller0/DEPLOY_SWITCH
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
TARGET=controller0
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
|
||||||
|
nixos-rebuild switch --flake "$DIR/../../#controller0" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller0/ISO
Executable file
10
nix/kubernetes/hosts/controller0/ISO
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#controller0.iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller0/SELF_BOOT
Executable file
10
nix/kubernetes/hosts/controller0/SELF_BOOT
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild boot --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#controller0" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller0/SELF_BUILD
Executable file
10
nix/kubernetes/hosts/controller0/SELF_BUILD
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild build --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#controller0" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller0/SELF_SWITCH
Executable file
10
nix/kubernetes/hosts/controller0/SELF_SWITCH
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild switch --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#controller0" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller0/VM_ISO
Executable file
10
nix/kubernetes/hosts/controller0/VM_ISO
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#controller0.vm_iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
130
nix/kubernetes/hosts/controller0/default.nix
Normal file
130
nix/kubernetes/hosts/controller0/default.nix
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
# MANUAL: On client machines generate signing keys:
|
||||||
|
# nix-store --generate-binary-cache-key some-name /persist/manual/nix/nix-cache-key.sec /persist/manual/nix/nix-cache-key.pub
|
||||||
|
#
|
||||||
|
# Trust other machines and add the substituters:
|
||||||
|
# nix.binaryCachePublicKeys = [ "some-name:AzNW1MOlkNEsUAXS1jIFZ1QCFKXjV+Y/LrF37quAZ1A=" ];
|
||||||
|
# nix.binaryCaches = [ "https://test.example/nix-cache" ];
|
||||||
|
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./hardware-configuration.nix
|
||||||
|
./vm_disk.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
networking =
|
||||||
|
let
|
||||||
|
interface = "enp0s2";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# Generate with `head -c4 /dev/urandom | od -A none -t x4`
|
||||||
|
hostId = "769e1349";
|
||||||
|
|
||||||
|
hostName = "controller0"; # Define your hostname.
|
||||||
|
|
||||||
|
interfaces = {
|
||||||
|
"${interface}" = {
|
||||||
|
ipv4.addresses = [
|
||||||
|
{
|
||||||
|
address = "10.215.1.221";
|
||||||
|
prefixLength = 24;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
ipv6.addresses = [
|
||||||
|
{
|
||||||
|
address = "2620:11f:7001:7:ffff:ffff:0ad7:01dd";
|
||||||
|
prefixLength = 64;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
defaultGateway = "10.215.1.1";
|
||||||
|
defaultGateway6 = {
|
||||||
|
# address = "2620:11f:7001:7::1";
|
||||||
|
address = "2620:11f:7001:7:ffff:ffff:0ad7:0101";
|
||||||
|
inherit interface;
|
||||||
|
};
|
||||||
|
|
||||||
|
dhcpcd.enable = lib.mkForce false;
|
||||||
|
useDHCP = lib.mkForce false;
|
||||||
|
};
|
||||||
|
|
||||||
|
time.timeZone = "America/New_York";
|
||||||
|
i18n.defaultLocale = "en_US.UTF-8";
|
||||||
|
|
||||||
|
me.boot.enable = true;
|
||||||
|
me.boot.secure = false;
|
||||||
|
me.mountPersistence = true;
|
||||||
|
boot.loader.timeout = lib.mkForce 0; # We can always generate a new ISO if we need to access other boot options.
|
||||||
|
|
||||||
|
me.optimizations = {
|
||||||
|
enable = true;
|
||||||
|
arch = "znver4";
|
||||||
|
# build_arch = "x86-64-v3";
|
||||||
|
system_features = [
|
||||||
|
"gccarch-znver4"
|
||||||
|
"gccarch-skylake"
|
||||||
|
"gccarch-kabylake"
|
||||||
|
# "gccarch-alderlake" missing WAITPKG
|
||||||
|
"gccarch-x86-64-v3"
|
||||||
|
"gccarch-x86-64-v4"
|
||||||
|
"benchmark"
|
||||||
|
"big-parallel"
|
||||||
|
"kvm"
|
||||||
|
"nixos-test"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Mount tmpfs at /tmp
|
||||||
|
boot.tmp.useTmpfs = true;
|
||||||
|
|
||||||
|
# Enable TRIM
|
||||||
|
# services.fstrim.enable = lib.mkDefault true;
|
||||||
|
|
||||||
|
# nix.optimise.automatic = true;
|
||||||
|
# nix.optimise.dates = [ "03:45" ];
|
||||||
|
# nix.optimise.persistent = true;
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
htop
|
||||||
|
];
|
||||||
|
|
||||||
|
# nix.sshServe.enable = true;
|
||||||
|
# nix.sshServe.keys = [ "ssh-dss AAAAB3NzaC1k... bob@example.org" ];
|
||||||
|
|
||||||
|
me.etcd.cluster_name = "put-a-nix-on-it";
|
||||||
|
me.etcd.internal_ip = [
|
||||||
|
# "10.215.1.221"
|
||||||
|
"[2620:11f:7001:7:ffff:ffff:0ad7:01dd]"
|
||||||
|
];
|
||||||
|
me.etcd.initial_cluster = [
|
||||||
|
# "controller0=https://10.215.1.221:2380" # 2620:11f:7001:7:ffff:ffff:0ad7:01dd
|
||||||
|
# "controller1=https://10.215.1.222:2380" # 2620:11f:7001:7:ffff:ffff:0ad7:01de
|
||||||
|
# "controller2=https://10.215.1.223:2380" # 2620:11f:7001:7:ffff:ffff:0ad7:01df
|
||||||
|
"controller0=https://[2620:11f:7001:7:ffff:ffff:0ad7:01dd]:2380" # 10.215.1.221
|
||||||
|
"controller1=https://[2620:11f:7001:7:ffff:ffff:0ad7:01de]:2380" # 10.215.1.222
|
||||||
|
"controller2=https://[2620:11f:7001:7:ffff:ffff:0ad7:01df]:2380" # 10.215.1.223
|
||||||
|
];
|
||||||
|
|
||||||
|
me.kube_apiserver.internal_ip = "2620:11f:7001:7:ffff:ffff:0ad7:01dd";
|
||||||
|
# me.kube_apiserver.external_ip = "74.80.180.138";
|
||||||
|
me.kube_apiserver.external_ip = "2620:11f:7001:7:ffff:ffff:0ad7:01dd";
|
||||||
|
me.kube_apiserver.etcd_services = [
|
||||||
|
"https://[2620:11f:7001:7:ffff:ffff:0ad7:01dd]:2379" # 10.215.1.221
|
||||||
|
"https://[2620:11f:7001:7:ffff:ffff:0ad7:01de]:2379" # 10.215.1.222
|
||||||
|
"https://[2620:11f:7001:7:ffff:ffff:0ad7:01df]:2379" # 10.215.1.223
|
||||||
|
];
|
||||||
|
|
||||||
|
me.control_plane.enable = true;
|
||||||
|
me.dont_use_substituters.enable = true;
|
||||||
|
me.etcd.enable = true;
|
||||||
|
me.minimal_base.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
31
nix/kubernetes/hosts/controller0/hardware-configuration.nix
Normal file
31
nix/kubernetes/hosts/controller0/hardware-configuration.nix
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
boot.initrd.availableKernelModules = [
|
||||||
|
"nvme"
|
||||||
|
"xhci_pci"
|
||||||
|
"thunderbolt"
|
||||||
|
];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||||
|
# networking.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.wlp58s0.useDHCP = lib.mkDefault true;
|
||||||
|
};
|
||||||
|
}
|
||||||
94
nix/kubernetes/hosts/controller0/vm_disk.nix
Normal file
94
nix/kubernetes/hosts/controller0/vm_disk.nix
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
# Mount the local disk
|
||||||
|
fileSystems = lib.mkIf config.me.mountPersistence {
|
||||||
|
"/.disk" = lib.mkForce {
|
||||||
|
device = "/dev/nvme0n1p1";
|
||||||
|
fsType = "ext4";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"discard"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/.persist" = lib.mkForce {
|
||||||
|
device = "bind9p";
|
||||||
|
fsType = "9p";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"trans=virtio"
|
||||||
|
"version=9p2000.L"
|
||||||
|
"cache=mmap"
|
||||||
|
"msize=512000"
|
||||||
|
# "noauto"
|
||||||
|
# "x-systemd.automount"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/persist" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.persist/persist";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.persist/persist"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/state" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.persist/state";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.persist/state"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/k8spv" = lib.mkForce {
|
||||||
|
device = "k8spv";
|
||||||
|
fsType = "9p";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"trans=virtio"
|
||||||
|
"version=9p2000.L"
|
||||||
|
"cache=mmap"
|
||||||
|
"msize=512000"
|
||||||
|
# "noauto"
|
||||||
|
# "x-systemd.automount"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/disk" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.disk/persist";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.disk/persist"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
13
nix/kubernetes/hosts/controller1/DEPLOY_BOOT
Executable file
13
nix/kubernetes/hosts/controller1/DEPLOY_BOOT
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
TARGET=controller1
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
|
||||||
|
nixos-rebuild boot --flake "$DIR/../../#controller1" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
13
nix/kubernetes/hosts/controller1/DEPLOY_SWITCH
Executable file
13
nix/kubernetes/hosts/controller1/DEPLOY_SWITCH
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
TARGET=controller1
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
|
||||||
|
nixos-rebuild switch --flake "$DIR/../../#controller1" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller1/ISO
Executable file
10
nix/kubernetes/hosts/controller1/ISO
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#controller1.iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller1/SELF_BOOT
Executable file
10
nix/kubernetes/hosts/controller1/SELF_BOOT
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild boot --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#controller1" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller1/SELF_BUILD
Executable file
10
nix/kubernetes/hosts/controller1/SELF_BUILD
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild build --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#controller1" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller1/SELF_SWITCH
Executable file
10
nix/kubernetes/hosts/controller1/SELF_SWITCH
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild switch --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#controller1" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller1/VM_ISO
Executable file
10
nix/kubernetes/hosts/controller1/VM_ISO
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#controller1.vm_iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
130
nix/kubernetes/hosts/controller1/default.nix
Normal file
130
nix/kubernetes/hosts/controller1/default.nix
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
# MANUAL: On client machines generate signing keys:
|
||||||
|
# nix-store --generate-binary-cache-key some-name /persist/manual/nix/nix-cache-key.sec /persist/manual/nix/nix-cache-key.pub
|
||||||
|
#
|
||||||
|
# Trust other machines and add the substituters:
|
||||||
|
# nix.binaryCachePublicKeys = [ "some-name:AzNW1MOlkNEsUAXS1jIFZ1QCFKXjV+Y/LrF37quAZ1A=" ];
|
||||||
|
# nix.binaryCaches = [ "https://test.example/nix-cache" ];
|
||||||
|
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./hardware-configuration.nix
|
||||||
|
./vm_disk.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
networking =
|
||||||
|
let
|
||||||
|
interface = "enp0s2";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# Generate with `head -c4 /dev/urandom | od -A none -t x4`
|
||||||
|
hostId = "59a83979";
|
||||||
|
|
||||||
|
hostName = "controller1"; # Define your hostname.
|
||||||
|
|
||||||
|
interfaces = {
|
||||||
|
"${interface}" = {
|
||||||
|
ipv4.addresses = [
|
||||||
|
{
|
||||||
|
address = "10.215.1.222";
|
||||||
|
prefixLength = 24;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
ipv6.addresses = [
|
||||||
|
{
|
||||||
|
address = "2620:11f:7001:7:ffff:ffff:0ad7:01de";
|
||||||
|
prefixLength = 64;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
defaultGateway = "10.215.1.1";
|
||||||
|
defaultGateway6 = {
|
||||||
|
# address = "2620:11f:7001:7::1";
|
||||||
|
address = "2620:11f:7001:7:ffff:ffff:0ad7:0101";
|
||||||
|
inherit interface;
|
||||||
|
};
|
||||||
|
|
||||||
|
dhcpcd.enable = lib.mkForce false;
|
||||||
|
useDHCP = lib.mkForce false;
|
||||||
|
};
|
||||||
|
|
||||||
|
time.timeZone = "America/New_York";
|
||||||
|
i18n.defaultLocale = "en_US.UTF-8";
|
||||||
|
|
||||||
|
me.boot.enable = true;
|
||||||
|
me.boot.secure = false;
|
||||||
|
me.mountPersistence = true;
|
||||||
|
boot.loader.timeout = lib.mkForce 0; # We can always generate a new ISO if we need to access other boot options.
|
||||||
|
|
||||||
|
me.optimizations = {
|
||||||
|
enable = true;
|
||||||
|
arch = "znver4";
|
||||||
|
# build_arch = "x86-64-v3";
|
||||||
|
system_features = [
|
||||||
|
"gccarch-znver4"
|
||||||
|
"gccarch-skylake"
|
||||||
|
"gccarch-kabylake"
|
||||||
|
# "gccarch-alderlake" missing WAITPKG
|
||||||
|
"gccarch-x86-64-v3"
|
||||||
|
"gccarch-x86-64-v4"
|
||||||
|
"benchmark"
|
||||||
|
"big-parallel"
|
||||||
|
"kvm"
|
||||||
|
"nixos-test"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Mount tmpfs at /tmp
|
||||||
|
boot.tmp.useTmpfs = true;
|
||||||
|
|
||||||
|
# Enable TRIM
|
||||||
|
# services.fstrim.enable = lib.mkDefault true;
|
||||||
|
|
||||||
|
# nix.optimise.automatic = true;
|
||||||
|
# nix.optimise.dates = [ "03:45" ];
|
||||||
|
# nix.optimise.persistent = true;
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
htop
|
||||||
|
];
|
||||||
|
|
||||||
|
# nix.sshServe.enable = true;
|
||||||
|
# nix.sshServe.keys = [ "ssh-dss AAAAB3NzaC1k... bob@example.org" ];
|
||||||
|
|
||||||
|
me.etcd.cluster_name = "put-a-nix-on-it";
|
||||||
|
me.etcd.internal_ip = [
|
||||||
|
# "10.215.1.221"
|
||||||
|
"[2620:11f:7001:7:ffff:ffff:0ad7:01de]"
|
||||||
|
];
|
||||||
|
me.etcd.initial_cluster = [
|
||||||
|
# "controller0=https://10.215.1.221:2380" # 2620:11f:7001:7:ffff:ffff:0ad7:01dd
|
||||||
|
# "controller1=https://10.215.1.222:2380" # 2620:11f:7001:7:ffff:ffff:0ad7:01de
|
||||||
|
# "controller2=https://10.215.1.223:2380" # 2620:11f:7001:7:ffff:ffff:0ad7:01df
|
||||||
|
"controller0=https://[2620:11f:7001:7:ffff:ffff:0ad7:01dd]:2380" # 10.215.1.221
|
||||||
|
"controller1=https://[2620:11f:7001:7:ffff:ffff:0ad7:01de]:2380" # 10.215.1.222
|
||||||
|
"controller2=https://[2620:11f:7001:7:ffff:ffff:0ad7:01df]:2380" # 10.215.1.223
|
||||||
|
];
|
||||||
|
|
||||||
|
me.kube_apiserver.internal_ip = "2620:11f:7001:7:ffff:ffff:0ad7:01de";
|
||||||
|
# me.kube_apiserver.external_ip = "74.80.180.138";
|
||||||
|
me.kube_apiserver.external_ip = "2620:11f:7001:7:ffff:ffff:0ad7:01de";
|
||||||
|
me.kube_apiserver.etcd_services = [
|
||||||
|
"https://[2620:11f:7001:7:ffff:ffff:0ad7:01dd]:2379" # 10.215.1.221
|
||||||
|
"https://[2620:11f:7001:7:ffff:ffff:0ad7:01de]:2379" # 10.215.1.222
|
||||||
|
"https://[2620:11f:7001:7:ffff:ffff:0ad7:01df]:2379" # 10.215.1.223
|
||||||
|
];
|
||||||
|
|
||||||
|
me.control_plane.enable = true;
|
||||||
|
me.dont_use_substituters.enable = true;
|
||||||
|
me.etcd.enable = true;
|
||||||
|
me.minimal_base.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
31
nix/kubernetes/hosts/controller1/hardware-configuration.nix
Normal file
31
nix/kubernetes/hosts/controller1/hardware-configuration.nix
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
boot.initrd.availableKernelModules = [
|
||||||
|
"nvme"
|
||||||
|
"xhci_pci"
|
||||||
|
"thunderbolt"
|
||||||
|
];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||||
|
# networking.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.wlp58s0.useDHCP = lib.mkDefault true;
|
||||||
|
};
|
||||||
|
}
|
||||||
94
nix/kubernetes/hosts/controller1/vm_disk.nix
Normal file
94
nix/kubernetes/hosts/controller1/vm_disk.nix
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
# Mount the local disk
|
||||||
|
fileSystems = lib.mkIf config.me.mountPersistence {
|
||||||
|
"/.disk" = lib.mkForce {
|
||||||
|
device = "/dev/nvme0n1p1";
|
||||||
|
fsType = "ext4";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"discard"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/.persist" = lib.mkForce {
|
||||||
|
device = "bind9p";
|
||||||
|
fsType = "9p";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"trans=virtio"
|
||||||
|
"version=9p2000.L"
|
||||||
|
"cache=mmap"
|
||||||
|
"msize=512000"
|
||||||
|
# "noauto"
|
||||||
|
# "x-systemd.automount"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/persist" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.persist/persist";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.persist/persist"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/state" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.persist/state";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.persist/state"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/k8spv" = lib.mkForce {
|
||||||
|
device = "k8spv";
|
||||||
|
fsType = "9p";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"trans=virtio"
|
||||||
|
"version=9p2000.L"
|
||||||
|
"cache=mmap"
|
||||||
|
"msize=512000"
|
||||||
|
# "noauto"
|
||||||
|
# "x-systemd.automount"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/disk" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.disk/persist";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.disk/persist"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
13
nix/kubernetes/hosts/controller2/DEPLOY_BOOT
Executable file
13
nix/kubernetes/hosts/controller2/DEPLOY_BOOT
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
TARGET=controller2
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
|
||||||
|
nixos-rebuild boot --flake "$DIR/../../#controller2" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
13
nix/kubernetes/hosts/controller2/DEPLOY_SWITCH
Executable file
13
nix/kubernetes/hosts/controller2/DEPLOY_SWITCH
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
TARGET=controller2
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
|
||||||
|
nixos-rebuild switch --flake "$DIR/../../#controller2" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller2/ISO
Executable file
10
nix/kubernetes/hosts/controller2/ISO
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#controller2.iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller2/SELF_BOOT
Executable file
10
nix/kubernetes/hosts/controller2/SELF_BOOT
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild boot --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#controller2" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller2/SELF_BUILD
Executable file
10
nix/kubernetes/hosts/controller2/SELF_BUILD
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild build --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#controller2" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller2/SELF_SWITCH
Executable file
10
nix/kubernetes/hosts/controller2/SELF_SWITCH
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild switch --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#controller2" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/controller2/VM_ISO
Executable file
10
nix/kubernetes/hosts/controller2/VM_ISO
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#controller2.vm_iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
130
nix/kubernetes/hosts/controller2/default.nix
Normal file
130
nix/kubernetes/hosts/controller2/default.nix
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
# MANUAL: On client machines generate signing keys:
|
||||||
|
# nix-store --generate-binary-cache-key some-name /persist/manual/nix/nix-cache-key.sec /persist/manual/nix/nix-cache-key.pub
|
||||||
|
#
|
||||||
|
# Trust other machines and add the substituters:
|
||||||
|
# nix.binaryCachePublicKeys = [ "some-name:AzNW1MOlkNEsUAXS1jIFZ1QCFKXjV+Y/LrF37quAZ1A=" ];
|
||||||
|
# nix.binaryCaches = [ "https://test.example/nix-cache" ];
|
||||||
|
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./hardware-configuration.nix
|
||||||
|
./vm_disk.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
networking =
|
||||||
|
let
|
||||||
|
interface = "enp0s2";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# Generate with `head -c4 /dev/urandom | od -A none -t x4`
|
||||||
|
hostId = "26a43660";
|
||||||
|
|
||||||
|
hostName = "controller2"; # Define your hostname.
|
||||||
|
|
||||||
|
interfaces = {
|
||||||
|
"${interface}" = {
|
||||||
|
ipv4.addresses = [
|
||||||
|
{
|
||||||
|
address = "10.215.1.223";
|
||||||
|
prefixLength = 24;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
ipv6.addresses = [
|
||||||
|
{
|
||||||
|
address = "2620:11f:7001:7:ffff:ffff:0ad7:01df";
|
||||||
|
prefixLength = 64;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
defaultGateway = "10.215.1.1";
|
||||||
|
defaultGateway6 = {
|
||||||
|
# address = "2620:11f:7001:7::1";
|
||||||
|
address = "2620:11f:7001:7:ffff:ffff:0ad7:0101";
|
||||||
|
inherit interface;
|
||||||
|
};
|
||||||
|
|
||||||
|
dhcpcd.enable = lib.mkForce false;
|
||||||
|
useDHCP = lib.mkForce false;
|
||||||
|
};
|
||||||
|
|
||||||
|
time.timeZone = "America/New_York";
|
||||||
|
i18n.defaultLocale = "en_US.UTF-8";
|
||||||
|
|
||||||
|
me.boot.enable = true;
|
||||||
|
me.boot.secure = false;
|
||||||
|
me.mountPersistence = true;
|
||||||
|
boot.loader.timeout = lib.mkForce 0; # We can always generate a new ISO if we need to access other boot options.
|
||||||
|
|
||||||
|
me.optimizations = {
|
||||||
|
enable = true;
|
||||||
|
arch = "znver4";
|
||||||
|
# build_arch = "x86-64-v3";
|
||||||
|
system_features = [
|
||||||
|
"gccarch-znver4"
|
||||||
|
"gccarch-skylake"
|
||||||
|
"gccarch-kabylake"
|
||||||
|
# "gccarch-alderlake" missing WAITPKG
|
||||||
|
"gccarch-x86-64-v3"
|
||||||
|
"gccarch-x86-64-v4"
|
||||||
|
"benchmark"
|
||||||
|
"big-parallel"
|
||||||
|
"kvm"
|
||||||
|
"nixos-test"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Mount tmpfs at /tmp
|
||||||
|
boot.tmp.useTmpfs = true;
|
||||||
|
|
||||||
|
# Enable TRIM
|
||||||
|
# services.fstrim.enable = lib.mkDefault true;
|
||||||
|
|
||||||
|
# nix.optimise.automatic = true;
|
||||||
|
# nix.optimise.dates = [ "03:45" ];
|
||||||
|
# nix.optimise.persistent = true;
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
htop
|
||||||
|
];
|
||||||
|
|
||||||
|
# nix.sshServe.enable = true;
|
||||||
|
# nix.sshServe.keys = [ "ssh-dss AAAAB3NzaC1k... bob@example.org" ];
|
||||||
|
|
||||||
|
me.etcd.cluster_name = "put-a-nix-on-it";
|
||||||
|
me.etcd.internal_ip = [
|
||||||
|
# "10.215.1.221"
|
||||||
|
"[2620:11f:7001:7:ffff:ffff:0ad7:01df]"
|
||||||
|
];
|
||||||
|
me.etcd.initial_cluster = [
|
||||||
|
# "controller0=https://10.215.1.221:2380" # 2620:11f:7001:7:ffff:ffff:0ad7:01dd
|
||||||
|
# "controller1=https://10.215.1.222:2380" # 2620:11f:7001:7:ffff:ffff:0ad7:01de
|
||||||
|
# "controller2=https://10.215.1.223:2380" # 2620:11f:7001:7:ffff:ffff:0ad7:01df
|
||||||
|
"controller0=https://[2620:11f:7001:7:ffff:ffff:0ad7:01dd]:2380" # 10.215.1.221
|
||||||
|
"controller1=https://[2620:11f:7001:7:ffff:ffff:0ad7:01de]:2380" # 10.215.1.222
|
||||||
|
"controller2=https://[2620:11f:7001:7:ffff:ffff:0ad7:01df]:2380" # 10.215.1.223
|
||||||
|
];
|
||||||
|
|
||||||
|
me.kube_apiserver.internal_ip = "2620:11f:7001:7:ffff:ffff:0ad7:01df";
|
||||||
|
# me.kube_apiserver.external_ip = "74.80.180.138";
|
||||||
|
me.kube_apiserver.external_ip = "2620:11f:7001:7:ffff:ffff:0ad7:01df";
|
||||||
|
me.kube_apiserver.etcd_services = [
|
||||||
|
"https://[2620:11f:7001:7:ffff:ffff:0ad7:01dd]:2379" # 10.215.1.221
|
||||||
|
"https://[2620:11f:7001:7:ffff:ffff:0ad7:01de]:2379" # 10.215.1.222
|
||||||
|
"https://[2620:11f:7001:7:ffff:ffff:0ad7:01df]:2379" # 10.215.1.223
|
||||||
|
];
|
||||||
|
|
||||||
|
me.control_plane.enable = true;
|
||||||
|
me.dont_use_substituters.enable = true;
|
||||||
|
me.etcd.enable = true;
|
||||||
|
me.minimal_base.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
31
nix/kubernetes/hosts/controller2/hardware-configuration.nix
Normal file
31
nix/kubernetes/hosts/controller2/hardware-configuration.nix
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
boot.initrd.availableKernelModules = [
|
||||||
|
"nvme"
|
||||||
|
"xhci_pci"
|
||||||
|
"thunderbolt"
|
||||||
|
];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||||
|
# networking.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.wlp58s0.useDHCP = lib.mkDefault true;
|
||||||
|
};
|
||||||
|
}
|
||||||
94
nix/kubernetes/hosts/controller2/vm_disk.nix
Normal file
94
nix/kubernetes/hosts/controller2/vm_disk.nix
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
# Mount the local disk
|
||||||
|
fileSystems = lib.mkIf config.me.mountPersistence {
|
||||||
|
"/.disk" = lib.mkForce {
|
||||||
|
device = "/dev/nvme0n1p1";
|
||||||
|
fsType = "ext4";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"discard"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/.persist" = lib.mkForce {
|
||||||
|
device = "bind9p";
|
||||||
|
fsType = "9p";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"trans=virtio"
|
||||||
|
"version=9p2000.L"
|
||||||
|
"cache=mmap"
|
||||||
|
"msize=512000"
|
||||||
|
# "noauto"
|
||||||
|
# "x-systemd.automount"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/persist" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.persist/persist";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.persist/persist"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/state" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.persist/state";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.persist/state"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/k8spv" = lib.mkForce {
|
||||||
|
device = "k8spv";
|
||||||
|
fsType = "9p";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"trans=virtio"
|
||||||
|
"version=9p2000.L"
|
||||||
|
"cache=mmap"
|
||||||
|
"msize=512000"
|
||||||
|
# "noauto"
|
||||||
|
# "x-systemd.automount"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/disk" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.disk/persist";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.disk/persist"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
13
nix/kubernetes/hosts/worker0/DEPLOY_BOOT
Executable file
13
nix/kubernetes/hosts/worker0/DEPLOY_BOOT
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
TARGET=worker0
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
|
||||||
|
nixos-rebuild boot --flake "$DIR/../../#worker0" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
13
nix/kubernetes/hosts/worker0/DEPLOY_SWITCH
Executable file
13
nix/kubernetes/hosts/worker0/DEPLOY_SWITCH
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
TARGET=worker0
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
|
||||||
|
nixos-rebuild switch --flake "$DIR/../../#worker0" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker0/ISO
Executable file
10
nix/kubernetes/hosts/worker0/ISO
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#worker0.iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker0/SELF_BOOT
Executable file
10
nix/kubernetes/hosts/worker0/SELF_BOOT
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild boot --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#worker0" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker0/SELF_BUILD
Executable file
10
nix/kubernetes/hosts/worker0/SELF_BUILD
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild build --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#worker0" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker0/SELF_SWITCH
Executable file
10
nix/kubernetes/hosts/worker0/SELF_SWITCH
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild switch --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#worker0" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker0/VM_ISO
Executable file
10
nix/kubernetes/hosts/worker0/VM_ISO
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#worker0.vm_iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
106
nix/kubernetes/hosts/worker0/default.nix
Normal file
106
nix/kubernetes/hosts/worker0/default.nix
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
# MANUAL: On client machines generate signing keys:
|
||||||
|
# nix-store --generate-binary-cache-key some-name /persist/manual/nix/nix-cache-key.sec /persist/manual/nix/nix-cache-key.pub
|
||||||
|
#
|
||||||
|
# Trust other machines and add the substituters:
|
||||||
|
# nix.binaryCachePublicKeys = [ "some-name:AzNW1MOlkNEsUAXS1jIFZ1QCFKXjV+Y/LrF37quAZ1A=" ];
|
||||||
|
# nix.binaryCaches = [ "https://test.example/nix-cache" ];
|
||||||
|
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./hardware-configuration.nix
|
||||||
|
./vm_disk.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
networking =
|
||||||
|
let
|
||||||
|
interface = "enp0s2";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# Generate with `head -c4 /dev/urandom | od -A none -t x4`
|
||||||
|
hostId = "0aadbb10";
|
||||||
|
|
||||||
|
hostName = "worker0"; # Define your hostname.
|
||||||
|
|
||||||
|
interfaces = {
|
||||||
|
"${interface}" = {
|
||||||
|
ipv4.addresses = [
|
||||||
|
{
|
||||||
|
address = "10.215.1.224";
|
||||||
|
prefixLength = 24;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
ipv6.addresses = [
|
||||||
|
{
|
||||||
|
address = "2620:11f:7001:7:ffff:ffff:0ad7:01e0";
|
||||||
|
prefixLength = 64;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
defaultGateway = "10.215.1.1";
|
||||||
|
defaultGateway6 = {
|
||||||
|
# address = "2620:11f:7001:7::1";
|
||||||
|
address = "2620:11f:7001:7:ffff:ffff:0ad7:0101";
|
||||||
|
inherit interface;
|
||||||
|
};
|
||||||
|
|
||||||
|
dhcpcd.enable = lib.mkForce false;
|
||||||
|
useDHCP = lib.mkForce false;
|
||||||
|
};
|
||||||
|
|
||||||
|
time.timeZone = "America/New_York";
|
||||||
|
i18n.defaultLocale = "en_US.UTF-8";
|
||||||
|
|
||||||
|
me.boot.enable = true;
|
||||||
|
me.boot.secure = false;
|
||||||
|
me.mountPersistence = true;
|
||||||
|
boot.loader.timeout = lib.mkForce 0; # We can always generate a new ISO if we need to access other boot options.
|
||||||
|
|
||||||
|
me.optimizations = {
|
||||||
|
enable = true;
|
||||||
|
arch = "znver4";
|
||||||
|
# build_arch = "x86-64-v3";
|
||||||
|
system_features = [
|
||||||
|
"gccarch-znver4"
|
||||||
|
"gccarch-skylake"
|
||||||
|
"gccarch-kabylake"
|
||||||
|
# "gccarch-alderlake" missing WAITPKG
|
||||||
|
"gccarch-x86-64-v3"
|
||||||
|
"gccarch-x86-64-v4"
|
||||||
|
"benchmark"
|
||||||
|
"big-parallel"
|
||||||
|
"kvm"
|
||||||
|
"nixos-test"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Mount tmpfs at /tmp
|
||||||
|
boot.tmp.useTmpfs = true;
|
||||||
|
|
||||||
|
# Enable TRIM
|
||||||
|
# services.fstrim.enable = lib.mkDefault true;
|
||||||
|
|
||||||
|
# nix.optimise.automatic = true;
|
||||||
|
# nix.optimise.dates = [ "03:45" ];
|
||||||
|
# nix.optimise.persistent = true;
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
htop
|
||||||
|
];
|
||||||
|
|
||||||
|
# nix.sshServe.enable = true;
|
||||||
|
# nix.sshServe.keys = [ "ssh-dss AAAAB3NzaC1k... bob@example.org" ];
|
||||||
|
|
||||||
|
me.dont_use_substituters.enable = true;
|
||||||
|
me.minimal_base.enable = true;
|
||||||
|
me.worker_node.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
31
nix/kubernetes/hosts/worker0/hardware-configuration.nix
Normal file
31
nix/kubernetes/hosts/worker0/hardware-configuration.nix
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
boot.initrd.availableKernelModules = [
|
||||||
|
"nvme"
|
||||||
|
"xhci_pci"
|
||||||
|
"thunderbolt"
|
||||||
|
];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||||
|
# networking.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.wlp58s0.useDHCP = lib.mkDefault true;
|
||||||
|
};
|
||||||
|
}
|
||||||
94
nix/kubernetes/hosts/worker0/vm_disk.nix
Normal file
94
nix/kubernetes/hosts/worker0/vm_disk.nix
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
# Mount the local disk
|
||||||
|
fileSystems = lib.mkIf config.me.mountPersistence {
|
||||||
|
"/.disk" = lib.mkForce {
|
||||||
|
device = "/dev/nvme0n1p1";
|
||||||
|
fsType = "ext4";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"discard"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/.persist" = lib.mkForce {
|
||||||
|
device = "bind9p";
|
||||||
|
fsType = "9p";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"trans=virtio"
|
||||||
|
"version=9p2000.L"
|
||||||
|
"cache=mmap"
|
||||||
|
"msize=512000"
|
||||||
|
# "noauto"
|
||||||
|
# "x-systemd.automount"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/persist" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.persist/persist";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.persist/persist"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/state" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.persist/state";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.persist/state"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/k8spv" = lib.mkForce {
|
||||||
|
device = "k8spv";
|
||||||
|
fsType = "9p";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"trans=virtio"
|
||||||
|
"version=9p2000.L"
|
||||||
|
"cache=mmap"
|
||||||
|
"msize=512000"
|
||||||
|
# "noauto"
|
||||||
|
# "x-systemd.automount"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/disk" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.disk/persist";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.disk/persist"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
13
nix/kubernetes/hosts/worker1/DEPLOY_BOOT
Executable file
13
nix/kubernetes/hosts/worker1/DEPLOY_BOOT
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
TARGET=worker1
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
|
||||||
|
nixos-rebuild boot --flake "$DIR/../../#worker1" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
13
nix/kubernetes/hosts/worker1/DEPLOY_SWITCH
Executable file
13
nix/kubernetes/hosts/worker1/DEPLOY_SWITCH
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
TARGET=worker1
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
|
||||||
|
nixos-rebuild switch --flake "$DIR/../../#worker1" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker1/ISO
Executable file
10
nix/kubernetes/hosts/worker1/ISO
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#worker1.iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker1/SELF_BOOT
Executable file
10
nix/kubernetes/hosts/worker1/SELF_BOOT
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild boot --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#worker1" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker1/SELF_BUILD
Executable file
10
nix/kubernetes/hosts/worker1/SELF_BUILD
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild build --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#worker1" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker1/SELF_SWITCH
Executable file
10
nix/kubernetes/hosts/worker1/SELF_SWITCH
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild switch --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#worker1" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker1/VM_ISO
Executable file
10
nix/kubernetes/hosts/worker1/VM_ISO
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#worker1.vm_iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
106
nix/kubernetes/hosts/worker1/default.nix
Normal file
106
nix/kubernetes/hosts/worker1/default.nix
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
# MANUAL: On client machines generate signing keys:
|
||||||
|
# nix-store --generate-binary-cache-key some-name /persist/manual/nix/nix-cache-key.sec /persist/manual/nix/nix-cache-key.pub
|
||||||
|
#
|
||||||
|
# Trust other machines and add the substituters:
|
||||||
|
# nix.binaryCachePublicKeys = [ "some-name:AzNW1MOlkNEsUAXS1jIFZ1QCFKXjV+Y/LrF37quAZ1A=" ];
|
||||||
|
# nix.binaryCaches = [ "https://test.example/nix-cache" ];
|
||||||
|
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./hardware-configuration.nix
|
||||||
|
./vm_disk.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
networking =
|
||||||
|
let
|
||||||
|
interface = "enp0s2";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# Generate with `head -c4 /dev/urandom | od -A none -t x4`
|
||||||
|
hostId = "4324346d";
|
||||||
|
|
||||||
|
hostName = "worker1"; # Define your hostname.
|
||||||
|
|
||||||
|
interfaces = {
|
||||||
|
"${interface}" = {
|
||||||
|
ipv4.addresses = [
|
||||||
|
{
|
||||||
|
address = "10.215.1.225";
|
||||||
|
prefixLength = 24;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
ipv6.addresses = [
|
||||||
|
{
|
||||||
|
address = "2620:11f:7001:7:ffff:ffff:0ad7:01e1";
|
||||||
|
prefixLength = 64;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
defaultGateway = "10.215.1.1";
|
||||||
|
defaultGateway6 = {
|
||||||
|
# address = "2620:11f:7001:7::1";
|
||||||
|
address = "2620:11f:7001:7:ffff:ffff:0ad7:0101";
|
||||||
|
inherit interface;
|
||||||
|
};
|
||||||
|
|
||||||
|
dhcpcd.enable = lib.mkForce false;
|
||||||
|
useDHCP = lib.mkForce false;
|
||||||
|
};
|
||||||
|
|
||||||
|
time.timeZone = "America/New_York";
|
||||||
|
i18n.defaultLocale = "en_US.UTF-8";
|
||||||
|
|
||||||
|
me.boot.enable = true;
|
||||||
|
me.boot.secure = false;
|
||||||
|
me.mountPersistence = true;
|
||||||
|
boot.loader.timeout = lib.mkForce 0; # We can always generate a new ISO if we need to access other boot options.
|
||||||
|
|
||||||
|
me.optimizations = {
|
||||||
|
enable = true;
|
||||||
|
arch = "znver4";
|
||||||
|
# build_arch = "x86-64-v3";
|
||||||
|
system_features = [
|
||||||
|
"gccarch-znver4"
|
||||||
|
"gccarch-skylake"
|
||||||
|
"gccarch-kabylake"
|
||||||
|
# "gccarch-alderlake" missing WAITPKG
|
||||||
|
"gccarch-x86-64-v3"
|
||||||
|
"gccarch-x86-64-v4"
|
||||||
|
"benchmark"
|
||||||
|
"big-parallel"
|
||||||
|
"kvm"
|
||||||
|
"nixos-test"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Mount tmpfs at /tmp
|
||||||
|
boot.tmp.useTmpfs = true;
|
||||||
|
|
||||||
|
# Enable TRIM
|
||||||
|
# services.fstrim.enable = lib.mkDefault true;
|
||||||
|
|
||||||
|
# nix.optimise.automatic = true;
|
||||||
|
# nix.optimise.dates = [ "03:45" ];
|
||||||
|
# nix.optimise.persistent = true;
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
htop
|
||||||
|
];
|
||||||
|
|
||||||
|
# nix.sshServe.enable = true;
|
||||||
|
# nix.sshServe.keys = [ "ssh-dss AAAAB3NzaC1k... bob@example.org" ];
|
||||||
|
|
||||||
|
me.worker_node.enable = true;
|
||||||
|
me.dont_use_substituters.enable = true;
|
||||||
|
me.minimal_base.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
31
nix/kubernetes/hosts/worker1/hardware-configuration.nix
Normal file
31
nix/kubernetes/hosts/worker1/hardware-configuration.nix
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
boot.initrd.availableKernelModules = [
|
||||||
|
"nvme"
|
||||||
|
"xhci_pci"
|
||||||
|
"thunderbolt"
|
||||||
|
];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||||
|
# networking.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.wlp58s0.useDHCP = lib.mkDefault true;
|
||||||
|
};
|
||||||
|
}
|
||||||
94
nix/kubernetes/hosts/worker1/vm_disk.nix
Normal file
94
nix/kubernetes/hosts/worker1/vm_disk.nix
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
# Mount the local disk
|
||||||
|
fileSystems = lib.mkIf config.me.mountPersistence {
|
||||||
|
"/.disk" = lib.mkForce {
|
||||||
|
device = "/dev/nvme0n1p1";
|
||||||
|
fsType = "ext4";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"discard"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/.persist" = lib.mkForce {
|
||||||
|
device = "bind9p";
|
||||||
|
fsType = "9p";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"trans=virtio"
|
||||||
|
"version=9p2000.L"
|
||||||
|
"cache=mmap"
|
||||||
|
"msize=512000"
|
||||||
|
# "noauto"
|
||||||
|
# "x-systemd.automount"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/persist" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.persist/persist";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.persist/persist"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/state" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.persist/state";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.persist/state"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/k8spv" = lib.mkForce {
|
||||||
|
device = "k8spv";
|
||||||
|
fsType = "9p";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"trans=virtio"
|
||||||
|
"version=9p2000.L"
|
||||||
|
"cache=mmap"
|
||||||
|
"msize=512000"
|
||||||
|
# "noauto"
|
||||||
|
# "x-systemd.automount"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/disk" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.disk/persist";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.disk/persist"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
13
nix/kubernetes/hosts/worker2/DEPLOY_BOOT
Executable file
13
nix/kubernetes/hosts/worker2/DEPLOY_BOOT
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
TARGET=worker2
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
|
||||||
|
nixos-rebuild boot --flake "$DIR/../../#worker2" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
13
nix/kubernetes/hosts/worker2/DEPLOY_SWITCH
Executable file
13
nix/kubernetes/hosts/worker2/DEPLOY_SWITCH
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
TARGET=worker2
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
|
||||||
|
nixos-rebuild switch --flake "$DIR/../../#worker2" --target-host "$TARGET" --build-host "$TARGET" --sudo --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker2/ISO
Executable file
10
nix/kubernetes/hosts/worker2/ISO
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#worker2.iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker2/SELF_BOOT
Executable file
10
nix/kubernetes/hosts/worker2/SELF_BOOT
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild boot --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#worker2" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker2/SELF_BUILD
Executable file
10
nix/kubernetes/hosts/worker2/SELF_BUILD
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild build --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#worker2" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker2/SELF_SWITCH
Executable file
10
nix/kubernetes/hosts/worker2/SELF_SWITCH
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nixos-rebuild switch --show-trace --sudo --max-jobs "$JOBS" --flake "$DIR/../../#worker2" --log-format internal-json -v "${@}" |& nom --json
|
||||||
10
nix/kubernetes/hosts/worker2/VM_ISO
Executable file
10
nix/kubernetes/hosts/worker2/VM_ISO
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
: "${JOBS:="1"}"
|
||||||
|
|
||||||
|
for f in /persist/manual/manual_add_to_store/*; do nix-store --add-fixed sha256 "$f"; done
|
||||||
|
nix build --extra-experimental-features nix-command --extra-experimental-features flakes "$DIR/../..#worker2.vm_iso" --max-jobs "$JOBS" --log-format internal-json -v "${@}" |& nom --json
|
||||||
106
nix/kubernetes/hosts/worker2/default.nix
Normal file
106
nix/kubernetes/hosts/worker2/default.nix
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
# MANUAL: On client machines generate signing keys:
|
||||||
|
# nix-store --generate-binary-cache-key some-name /persist/manual/nix/nix-cache-key.sec /persist/manual/nix/nix-cache-key.pub
|
||||||
|
#
|
||||||
|
# Trust other machines and add the substituters:
|
||||||
|
# nix.binaryCachePublicKeys = [ "some-name:AzNW1MOlkNEsUAXS1jIFZ1QCFKXjV+Y/LrF37quAZ1A=" ];
|
||||||
|
# nix.binaryCaches = [ "https://test.example/nix-cache" ];
|
||||||
|
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./hardware-configuration.nix
|
||||||
|
./vm_disk.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
networking =
|
||||||
|
let
|
||||||
|
interface = "enp0s2";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
# Generate with `head -c4 /dev/urandom | od -A none -t x4`
|
||||||
|
hostId = "ce017961";
|
||||||
|
|
||||||
|
hostName = "worker2"; # Define your hostname.
|
||||||
|
|
||||||
|
interfaces = {
|
||||||
|
"${interface}" = {
|
||||||
|
ipv4.addresses = [
|
||||||
|
{
|
||||||
|
address = "10.215.1.226";
|
||||||
|
prefixLength = 24;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
ipv6.addresses = [
|
||||||
|
{
|
||||||
|
address = "2620:11f:7001:7:ffff:ffff:0ad7:01e2";
|
||||||
|
prefixLength = 64;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
defaultGateway = "10.215.1.1";
|
||||||
|
defaultGateway6 = {
|
||||||
|
# address = "2620:11f:7001:7::1";
|
||||||
|
address = "2620:11f:7001:7:ffff:ffff:0ad7:0101";
|
||||||
|
inherit interface;
|
||||||
|
};
|
||||||
|
|
||||||
|
dhcpcd.enable = lib.mkForce false;
|
||||||
|
useDHCP = lib.mkForce false;
|
||||||
|
};
|
||||||
|
|
||||||
|
time.timeZone = "America/New_York";
|
||||||
|
i18n.defaultLocale = "en_US.UTF-8";
|
||||||
|
|
||||||
|
me.boot.enable = true;
|
||||||
|
me.boot.secure = false;
|
||||||
|
me.mountPersistence = true;
|
||||||
|
boot.loader.timeout = lib.mkForce 0; # We can always generate a new ISO if we need to access other boot options.
|
||||||
|
|
||||||
|
me.optimizations = {
|
||||||
|
enable = true;
|
||||||
|
arch = "znver4";
|
||||||
|
# build_arch = "x86-64-v3";
|
||||||
|
system_features = [
|
||||||
|
"gccarch-znver4"
|
||||||
|
"gccarch-skylake"
|
||||||
|
"gccarch-kabylake"
|
||||||
|
# "gccarch-alderlake" missing WAITPKG
|
||||||
|
"gccarch-x86-64-v3"
|
||||||
|
"gccarch-x86-64-v4"
|
||||||
|
"benchmark"
|
||||||
|
"big-parallel"
|
||||||
|
"kvm"
|
||||||
|
"nixos-test"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Mount tmpfs at /tmp
|
||||||
|
boot.tmp.useTmpfs = true;
|
||||||
|
|
||||||
|
# Enable TRIM
|
||||||
|
# services.fstrim.enable = lib.mkDefault true;
|
||||||
|
|
||||||
|
# nix.optimise.automatic = true;
|
||||||
|
# nix.optimise.dates = [ "03:45" ];
|
||||||
|
# nix.optimise.persistent = true;
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
htop
|
||||||
|
];
|
||||||
|
|
||||||
|
# nix.sshServe.enable = true;
|
||||||
|
# nix.sshServe.keys = [ "ssh-dss AAAAB3NzaC1k... bob@example.org" ];
|
||||||
|
|
||||||
|
me.worker_node.enable = true;
|
||||||
|
me.dont_use_substituters.enable = true;
|
||||||
|
me.minimal_base.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
31
nix/kubernetes/hosts/worker2/hardware-configuration.nix
Normal file
31
nix/kubernetes/hosts/worker2/hardware-configuration.nix
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
modulesPath,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
(modulesPath + "/installer/scan/not-detected.nix")
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
boot.initrd.availableKernelModules = [
|
||||||
|
"nvme"
|
||||||
|
"xhci_pci"
|
||||||
|
"thunderbolt"
|
||||||
|
];
|
||||||
|
boot.initrd.kernelModules = [ ];
|
||||||
|
boot.kernelModules = [ ];
|
||||||
|
boot.extraModulePackages = [ ];
|
||||||
|
|
||||||
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||||
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||||
|
# still possible to use this option, but it's recommended to use it in conjunction
|
||||||
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||||
|
# networking.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.eno1.useDHCP = lib.mkDefault true;
|
||||||
|
# networking.interfaces.wlp58s0.useDHCP = lib.mkDefault true;
|
||||||
|
};
|
||||||
|
}
|
||||||
94
nix/kubernetes/hosts/worker2/vm_disk.nix
Normal file
94
nix/kubernetes/hosts/worker2/vm_disk.nix
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [ ];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
# Mount the local disk
|
||||||
|
fileSystems = lib.mkIf config.me.mountPersistence {
|
||||||
|
"/.disk" = lib.mkForce {
|
||||||
|
device = "/dev/nvme0n1p1";
|
||||||
|
fsType = "ext4";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"discard"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/.persist" = lib.mkForce {
|
||||||
|
device = "bind9p";
|
||||||
|
fsType = "9p";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"trans=virtio"
|
||||||
|
"version=9p2000.L"
|
||||||
|
"cache=mmap"
|
||||||
|
"msize=512000"
|
||||||
|
# "noauto"
|
||||||
|
# "x-systemd.automount"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/persist" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.persist/persist";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.persist/persist"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/state" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.persist/state";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.persist/state"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/k8spv" = lib.mkForce {
|
||||||
|
device = "k8spv";
|
||||||
|
fsType = "9p";
|
||||||
|
options = [
|
||||||
|
"noatime"
|
||||||
|
"trans=virtio"
|
||||||
|
"version=9p2000.L"
|
||||||
|
"cache=mmap"
|
||||||
|
"msize=512000"
|
||||||
|
# "noauto"
|
||||||
|
# "x-systemd.automount"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
"/disk" = {
|
||||||
|
fsType = "none";
|
||||||
|
device = "/.disk/persist";
|
||||||
|
options = [
|
||||||
|
"bind"
|
||||||
|
"rw"
|
||||||
|
];
|
||||||
|
depends = [
|
||||||
|
"/.disk/persist"
|
||||||
|
];
|
||||||
|
neededForBoot = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
29
nix/kubernetes/keys/Makefile
Normal file
29
nix/kubernetes/keys/Makefile
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
SHELL := bash
|
||||||
|
.ONESHELL:
|
||||||
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
|
.DELETE_ON_ERROR:
|
||||||
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
MAKEFLAGS += --no-builtin-rules
|
||||||
|
OUT=generated
|
||||||
|
|
||||||
|
ifeq ($(origin .RECIPEPREFIX), undefined)
|
||||||
|
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
|
||||||
|
endif
|
||||||
|
.RECIPEPREFIX = >
|
||||||
|
|
||||||
|
KUBERNETES_PUBLIC_ADDRESS := 74.80.180.138
|
||||||
|
WORKERS := worker0 worker1 worker2 controller0 controller1 controller2
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: \
|
||||||
|
$(OUT)/known_hosts
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
> rm -rf $(OUT)
|
||||||
|
|
||||||
|
$(OUT)/:
|
||||||
|
> @mkdir -p $(@D)
|
||||||
|
|
||||||
|
$(OUT)/known_hosts: | $(OUT)/
|
||||||
|
> ssh-keyscan -p 65099 74.80.180.138 | sed 's/\[74.80.180.138\]:65099/\[10.215.1.210\]:22/g' > $@
|
||||||
62
nix/kubernetes/keys/contrib/base64/package.nix
Normal file
62
nix/kubernetes/keys/contrib/base64/package.nix
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
# From: https://gist.github.com/manveru/74eb41d850bc146b7e78c4cb059507e2
|
||||||
|
# From: https://discourse.nixos.org/t/string-to-base-64/32624/3
|
||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
toBase64 =
|
||||||
|
text:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
sublist
|
||||||
|
mod
|
||||||
|
stringToCharacters
|
||||||
|
concatMapStrings
|
||||||
|
;
|
||||||
|
inherit (lib.strings) charToInt;
|
||||||
|
inherit (builtins)
|
||||||
|
substring
|
||||||
|
foldl'
|
||||||
|
genList
|
||||||
|
elemAt
|
||||||
|
length
|
||||||
|
concatStringsSep
|
||||||
|
stringLength
|
||||||
|
;
|
||||||
|
lookup = stringToCharacters "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
sliceN =
|
||||||
|
size: list: n:
|
||||||
|
sublist (n * size) size list;
|
||||||
|
pows = [
|
||||||
|
(64 * 64 * 64)
|
||||||
|
(64 * 64)
|
||||||
|
64
|
||||||
|
1
|
||||||
|
];
|
||||||
|
intSextets = i: map (j: mod (i / j) 64) pows;
|
||||||
|
compose =
|
||||||
|
f: g: x:
|
||||||
|
f (g x);
|
||||||
|
intToChar = elemAt lookup;
|
||||||
|
convertTripletInt = sliceInt: concatMapStrings intToChar (intSextets sliceInt);
|
||||||
|
sliceToInt = foldl' (acc: val: acc * 256 + val) 0;
|
||||||
|
convertTriplet = compose convertTripletInt sliceToInt;
|
||||||
|
join = concatStringsSep "";
|
||||||
|
convertLastSlice =
|
||||||
|
slice:
|
||||||
|
let
|
||||||
|
len = length slice;
|
||||||
|
in
|
||||||
|
if len == 1 then
|
||||||
|
(substring 0 2 (convertTripletInt ((sliceToInt slice) * 256 * 256))) + "=="
|
||||||
|
else if len == 2 then
|
||||||
|
(substring 0 3 (convertTripletInt ((sliceToInt slice) * 256))) + "="
|
||||||
|
else
|
||||||
|
"";
|
||||||
|
len = stringLength text;
|
||||||
|
nFullSlices = len / 3;
|
||||||
|
bytes = map charToInt (stringToCharacters text);
|
||||||
|
tripletAt = sliceN 3 bytes;
|
||||||
|
head = genList (compose convertTriplet tripletAt) nFullSlices;
|
||||||
|
tail = convertLastSlice (tripletAt nFullSlices);
|
||||||
|
in
|
||||||
|
join (head ++ [ tail ]);
|
||||||
|
}
|
||||||
27
nix/kubernetes/keys/flake.lock
generated
Normal file
27
nix/kubernetes/keys/flake.lock
generated
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1772773019,
|
||||||
|
"narHash": "sha256-E1bxHxNKfDoQUuvriG71+f+s/NT0qWkImXsYZNFFfCs=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "aca4d95fce4914b3892661bcb80b8087293536c6",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
56
nix/kubernetes/keys/flake.nix
Normal file
56
nix/kubernetes/keys/flake.nix
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
description = "Build keys to manually deploy to kubernetes cluster.";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{ self, nixpkgs }:
|
||||||
|
let
|
||||||
|
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages = forAllSystems (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ self.overlays.default ];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
deploy_script = pkgs.k8s.deploy_script;
|
||||||
|
default = pkgs.k8s.all_keys;
|
||||||
|
bootstrap_script = pkgs.k8s.bootstrap_script;
|
||||||
|
mrmanager_repo_secrets = pkgs.k8s.mrmanager_repo_secrets;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
overlays.default = (
|
||||||
|
final: prev: {
|
||||||
|
k8s = (final.callPackage ./scope.nix { inherit (final.lib) makeScope; });
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
// {
|
||||||
|
devShells = forAllSystems (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
pkg-config
|
||||||
|
];
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
kubernetes-helm # To generate cilium manifests
|
||||||
|
fluxcd # To generate flux manifests
|
||||||
|
cilium-cli # To check cilium status
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
8
nix/kubernetes/keys/generated/known_hosts
Normal file
8
nix/kubernetes/keys/generated/known_hosts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# 74.80.180.138:65099 SSH-2.0-OpenSSH_9.3 FreeBSD-20230316
|
||||||
|
[10.215.1.210]:22 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC0hWY7Ighnlp3UfPfApyW9nEGG11f+on/kOkp6YdxTTVX0jvi00xvrZ8c23l48YDptmEKOMj7avUR+jdpRNaSwbw3Lm7swg+EpFZ73tnHK+r6HnOnNu8ECDvYOW10eI6vdRctFisRfyIKigmtmquxXYLhQDSA2INVW+Vuebdwa74VqKLLirUu7e3ymp8dH8ktcCAjWSd/+Ax7E+4AMa5WHFeTPBheA2GhfLhINDLpgdZ8WNZ4i3ow8MrQADiOVYUDPrXvI55MVWSQTQQcOco184Z67rtcCtqY/fcCp+38yzUT0Bm2syXM+HNOlFqM+fJBf0T9kiiy5XvWuN9bY+368JGOUUM6RsCUgERHSaU65nX3i8oIcNRt3w6sVsmRR8sX8x5qFjyEYuElIwKywcdtKpoklV6gu+lo+mIE8i95jJmXMj6lk3G83wMZICL9+dm+b8ckpRZEi6970EqahiPO3cV/Fa88gysf9HwiC8AxSc3m2BcOvaV3jadaT39Tymp8=
|
||||||
|
# 74.80.180.138:65099 SSH-2.0-OpenSSH_9.3 FreeBSD-20230316
|
||||||
|
# 74.80.180.138:65099 SSH-2.0-OpenSSH_9.3 FreeBSD-20230316
|
||||||
|
[10.215.1.210]:22 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBH2euFJKLEDfTV9NTecrOoqL9FpiYvTbNp/Ty3FebJA5DKmVd1xBRz3sNs1R1ayn213vmRVLWSu2ikulbl65LLQ=
|
||||||
|
# 74.80.180.138:65099 SSH-2.0-OpenSSH_9.3 FreeBSD-20230316
|
||||||
|
[10.215.1.210]:22 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM1qjGgD2UdD5Lc+zGFxHX/+h6FBNmGW+O30LG0tiHvC
|
||||||
|
# 74.80.180.138:65099 SSH-2.0-OpenSSH_9.3 FreeBSD-20230316
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,50 @@
|
|||||||
|
apiVersion: source.toolkit.fluxcd.io/v1
|
||||||
|
kind: GitRepository
|
||||||
|
metadata:
|
||||||
|
name: kubernetes
|
||||||
|
namespace: flux-system
|
||||||
|
spec:
|
||||||
|
interval: 5m0s
|
||||||
|
ref:
|
||||||
|
branch: nix
|
||||||
|
secretRef:
|
||||||
|
name: kubernetes-deploy-key
|
||||||
|
# url: ssh://git@74.80.180.138:65099/repos/mrmanager
|
||||||
|
url: ssh://git@10.215.1.210:22/repos/mrmanager
|
||||||
|
ignore: |
|
||||||
|
bootstrap
|
||||||
|
.sops.yaml
|
||||||
|
---
|
||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: apply1
|
||||||
|
namespace: flux-system
|
||||||
|
spec:
|
||||||
|
interval: 1m0s
|
||||||
|
path: "./k8s/1"
|
||||||
|
prune: true
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: kubernetes
|
||||||
|
decryption:
|
||||||
|
provider: sops
|
||||||
|
secretRef:
|
||||||
|
name: sops-gpg
|
||||||
|
---
|
||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: apply2
|
||||||
|
namespace: flux-system
|
||||||
|
spec:
|
||||||
|
interval: 1m0s
|
||||||
|
path: "./k8s/2"
|
||||||
|
prune: true
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: kubernetes
|
||||||
|
decryption:
|
||||||
|
provider: sops
|
||||||
|
secretRef:
|
||||||
|
name: sops-gpg
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: fluxcd.controlplane.io/v1
|
||||||
|
kind: FluxInstance
|
||||||
|
metadata:
|
||||||
|
name: flux
|
||||||
|
namespace: flux-system
|
||||||
|
spec:
|
||||||
|
distribution:
|
||||||
|
version: "2.8.x"
|
||||||
|
registry: "ghcr.io/fluxcd"
|
||||||
|
components:
|
||||||
|
- source-controller
|
||||||
|
- kustomize-controller
|
||||||
|
- helm-controller
|
||||||
|
- notification-controller
|
||||||
|
- image-automation-controller
|
||||||
|
- image-reflector-controller
|
||||||
|
# - source-watcher
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: flux-system
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRole
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
rbac.authorization.kubernetes.io/autoupdate: "true"
|
||||||
|
labels:
|
||||||
|
kubernetes.io/bootstrapping: rbac-defaults
|
||||||
|
name: system:kube-apiserver-to-kubelet
|
||||||
|
rules:
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- nodes/proxy
|
||||||
|
- nodes/stats
|
||||||
|
- nodes/log
|
||||||
|
- nodes/spec
|
||||||
|
- nodes/metrics
|
||||||
|
verbs:
|
||||||
|
- "*"
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
metadata:
|
||||||
|
name: system:kube-apiserver
|
||||||
|
namespace: ""
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: ClusterRole
|
||||||
|
name: system:kube-apiserver-to-kubelet
|
||||||
|
subjects:
|
||||||
|
- apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: User
|
||||||
|
name: kubernetes
|
||||||
86
nix/kubernetes/keys/package/bootstrap-script/package.nix
Normal file
86
nix/kubernetes/keys/package/bootstrap-script/package.nix
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
# unpackPhase
|
||||||
|
# patchPhase
|
||||||
|
# configurePhase
|
||||||
|
# buildPhase
|
||||||
|
# checkPhase
|
||||||
|
# installPhase
|
||||||
|
# fixupPhase
|
||||||
|
# installCheckPhase
|
||||||
|
# distPhase
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
stdenv,
|
||||||
|
fetchFromGitHub,
|
||||||
|
writeShellScript,
|
||||||
|
k8s,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
bootstrap_script = (writeShellScript "bootstrap-script" bootstrap_script_body);
|
||||||
|
bootstrap_script_body = (''
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "''${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
${apply_manifests}
|
||||||
|
echo "Bootstrap finished"
|
||||||
|
'');
|
||||||
|
manifests = (
|
||||||
|
lib.concatMapStringsSep "," lib.escapeShellArg (
|
||||||
|
[
|
||||||
|
./files/manifests/initial_clusterrole.yaml
|
||||||
|
]
|
||||||
|
++ gateway_crds
|
||||||
|
++ [
|
||||||
|
"${k8s.cilium-manifest}/cilium.yaml"
|
||||||
|
"${k8s.coredns-manifest}/coredns.yaml"
|
||||||
|
./files/manifests/flux_namespace.yaml
|
||||||
|
|
||||||
|
#
|
||||||
|
# Generate with: helm template --dry-run=server flux-operator oci://ghcr.io/controlplaneio-fluxcd/charts/flux-operator --namespace flux-system --create-namespace
|
||||||
|
#
|
||||||
|
./files/manifests/flux.yaml
|
||||||
|
./files/manifests/flux_instance.yaml
|
||||||
|
]
|
||||||
|
++ (lib.attrsets.mapAttrsToList (
|
||||||
|
secret_name: secret_value: "${secret_value}/${secret_name}.yaml"
|
||||||
|
) k8s.k8s-secrets-generic)
|
||||||
|
++ [
|
||||||
|
./files/manifests/flux_apply_git.yaml
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
apply_manifests = "kubectl --kubeconfig=${k8s.client-configs.admin}/admin.kubeconfig apply --server-side --force-conflicts -f ${manifests}";
|
||||||
|
gateway_crds_repo = fetchFromGitHub {
|
||||||
|
owner = "kubernetes-sigs";
|
||||||
|
repo = "gateway-api";
|
||||||
|
rev = "v1.5.1";
|
||||||
|
sha256 = "sha256-mWMvJG6esOqDBSbhExvt7L3ZTiQUOfeRBohew/m67A0=";
|
||||||
|
};
|
||||||
|
gateway_crds = [
|
||||||
|
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_backendtlspolicies.yaml"
|
||||||
|
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_gatewayclasses.yaml"
|
||||||
|
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_gateways.yaml"
|
||||||
|
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_grpcroutes.yaml"
|
||||||
|
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_httproutes.yaml"
|
||||||
|
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_listenersets.yaml"
|
||||||
|
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_referencegrants.yaml"
|
||||||
|
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_tcproutes.yaml"
|
||||||
|
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_tlsroutes.yaml"
|
||||||
|
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_udproutes.yaml"
|
||||||
|
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.k8s.io_vap_safeupgrades.yaml"
|
||||||
|
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.x-k8s.io_xbackendtrafficpolicies.yaml"
|
||||||
|
"${gateway_crds_repo}/config/crd/experimental/gateway.networking.x-k8s.io_xmeshes.yaml"
|
||||||
|
];
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
|
name = "bootstrap-script";
|
||||||
|
nativeBuildInputs = [ ];
|
||||||
|
buildInputs = [ ];
|
||||||
|
|
||||||
|
unpackPhase = "true";
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
cp ${bootstrap_script} "$out"
|
||||||
|
'';
|
||||||
|
})
|
||||||
369
nix/kubernetes/keys/package/deploy-script/package.nix
Normal file
369
nix/kubernetes/keys/package/deploy-script/package.nix
Normal file
@@ -0,0 +1,369 @@
|
|||||||
|
# unpackPhase
|
||||||
|
# patchPhase
|
||||||
|
# configurePhase
|
||||||
|
# buildPhase
|
||||||
|
# checkPhase
|
||||||
|
# installPhase
|
||||||
|
# fixupPhase
|
||||||
|
# installCheckPhase
|
||||||
|
# distPhase
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
stdenv,
|
||||||
|
writeShellScript,
|
||||||
|
k8s,
|
||||||
|
openssh,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
vm_name_to_hostname =
|
||||||
|
let
|
||||||
|
mapping = {
|
||||||
|
"nc0" = "controller0";
|
||||||
|
"nc1" = "controller1";
|
||||||
|
"nc2" = "controller2";
|
||||||
|
"nw0" = "worker0";
|
||||||
|
"nw1" = "worker1";
|
||||||
|
"nw2" = "worker2";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
(vm_name: mapping."${vm_name}");
|
||||||
|
|
||||||
|
deploy_script_body = (
|
||||||
|
''
|
||||||
|
set -euo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
DIR="$( cd "$( dirname "''${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
''
|
||||||
|
+ (lib.concatMapStringsSep "\n" deploy_control_plane [
|
||||||
|
"nc0"
|
||||||
|
"nc1"
|
||||||
|
"nc2"
|
||||||
|
])
|
||||||
|
+ (lib.concatMapStringsSep "\n" deploy_worker [
|
||||||
|
"nw0"
|
||||||
|
"nw1"
|
||||||
|
"nw2"
|
||||||
|
])
|
||||||
|
+ (trust_ssh_key {
|
||||||
|
public_key = "${k8s.ssh-keys.flux_ssh_key}/flux_ssh_key.pub";
|
||||||
|
destination = "/jail/admin_git/usr/home/git/.ssh/authorized_keys";
|
||||||
|
owner = "11236";
|
||||||
|
group = "11236";
|
||||||
|
mode = "0600";
|
||||||
|
})
|
||||||
|
+ (lib.concatMapStringsSep "\n" create_pv_dir [
|
||||||
|
{
|
||||||
|
path = "manual-pv/gitea-psql";
|
||||||
|
owner = "26";
|
||||||
|
group = "26";
|
||||||
|
mode = "0777";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
path = "manual-pv/harbor-psql";
|
||||||
|
owner = "26";
|
||||||
|
group = "26";
|
||||||
|
mode = "0755";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
path = "manual-pv/ncps-psql";
|
||||||
|
owner = "26";
|
||||||
|
group = "26";
|
||||||
|
mode = "0755";
|
||||||
|
}
|
||||||
|
# {
|
||||||
|
# path = "manual-pv/gitea";
|
||||||
|
# owner = "1000";
|
||||||
|
# group = "1000";
|
||||||
|
# mode = "0777";
|
||||||
|
# }
|
||||||
|
# {
|
||||||
|
# path = "manual-pv/gitea/gitea";
|
||||||
|
# owner = "1000";
|
||||||
|
# group = "1000";
|
||||||
|
# mode = "0700";
|
||||||
|
# }
|
||||||
|
# {
|
||||||
|
# path = "manual-pv/gitea/gitea/public";
|
||||||
|
# owner = "1000";
|
||||||
|
# group = "1000";
|
||||||
|
# mode = "0755";
|
||||||
|
# }
|
||||||
|
])
|
||||||
|
|
||||||
|
);
|
||||||
|
deploy_script = (writeShellScript "deploy-script" deploy_script_body);
|
||||||
|
deploy_file = (
|
||||||
|
{
|
||||||
|
dest_dir,
|
||||||
|
file,
|
||||||
|
name ? (builtins.baseNameOf file),
|
||||||
|
owner,
|
||||||
|
group,
|
||||||
|
mode,
|
||||||
|
}:
|
||||||
|
''
|
||||||
|
##
|
||||||
|
## deploy ${name} to ${dest_dir}
|
||||||
|
##
|
||||||
|
${openssh}/bin/ssh mrmanager doas rm -f ${dest_dir}/${name} ~/${name}
|
||||||
|
${openssh}/bin/scp ${file} mrmanager:~/${name}
|
||||||
|
${openssh}/bin/ssh mrmanager doas install -o ${toString owner} -g ${toString group} -m ${mode} ~/${name} ${dest_dir}/${name}
|
||||||
|
${openssh}/bin/ssh mrmanager doas rm -f ~/${name}
|
||||||
|
|
||||||
|
|
||||||
|
''
|
||||||
|
);
|
||||||
|
deploy_control_plane = (
|
||||||
|
vm_name:
|
||||||
|
(
|
||||||
|
''
|
||||||
|
##
|
||||||
|
## Create directories on ${vm_name}
|
||||||
|
##
|
||||||
|
${openssh}/bin/ssh mrmanager doas install -d -o 0 -g 0 -m 0755 /vm/${vm_name}/persist/keys
|
||||||
|
${openssh}/bin/ssh mrmanager doas install -d -o 10016 -g 10016 -m 0755 /vm/${vm_name}/persist/keys/etcd
|
||||||
|
${openssh}/bin/ssh mrmanager doas install -d -o 10024 -g 10024 -m 0755 /vm/${vm_name}/persist/keys/kube
|
||||||
|
''
|
||||||
|
+ (lib.concatMapStringsSep "\n" deploy_file [
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/etcd";
|
||||||
|
file = "${k8s.keys.kube-api-server}/kube-api-server.crt";
|
||||||
|
owner = 10016;
|
||||||
|
group = 10016;
|
||||||
|
mode = "0640";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/etcd";
|
||||||
|
file = "${k8s.keys.kube-api-server}/kube-api-server.key";
|
||||||
|
owner = 10016;
|
||||||
|
group = 10016;
|
||||||
|
mode = "0600";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/etcd";
|
||||||
|
file = "${k8s.ca.client}/client-ca.crt";
|
||||||
|
owner = 10016;
|
||||||
|
group = 10016;
|
||||||
|
mode = "0640";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.ca.client}/client-ca.crt";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0640";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.ca.client}/client-ca.key";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0600";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.keys.kube-api-server}/kube-api-server.crt";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0640";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.keys.kube-api-server}/kube-api-server.key";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0600";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.encryption_config}/encryption-config.yaml";
|
||||||
|
name = "encryption-config.yaml";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0600";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.keys.service-accounts}/service-accounts.crt";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0640";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.keys.service-accounts}/service-accounts.key";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0600";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.client-configs.kube-controller-manager}/kube-controller-manager.kubeconfig";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0600";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.client-configs.kube-scheduler}/kube-scheduler.kubeconfig";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0600";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.ca.requestheader-client}/requestheader-client-ca.crt";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0640";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${
|
||||||
|
k8s.keys."${vm_name_to_hostname vm_name}-proxy"
|
||||||
|
}/${vm_name_to_hostname vm_name}-proxy.crt";
|
||||||
|
name = "proxy.crt";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0640";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${
|
||||||
|
k8s.keys."${vm_name_to_hostname vm_name}-proxy"
|
||||||
|
}/${vm_name_to_hostname vm_name}-proxy.key";
|
||||||
|
name = "proxy.key";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0600";
|
||||||
|
}
|
||||||
|
])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
deploy_worker = (
|
||||||
|
vm_name:
|
||||||
|
(
|
||||||
|
''
|
||||||
|
##
|
||||||
|
## Create directories on ${vm_name}
|
||||||
|
##
|
||||||
|
${openssh}/bin/ssh mrmanager doas install -d -o 0 -g 0 -m 0755 /vm/${vm_name}/persist/keys
|
||||||
|
${openssh}/bin/ssh mrmanager doas install -d -o 10024 -g 10024 -m 0755 /vm/${vm_name}/persist/keys/kube
|
||||||
|
|
||||||
|
${openssh}/bin/ssh mrmanager doas install -d -o 0 -g 0 -m 0700 /vm/${vm_name}/persist/containerd/certs.d/docker.io
|
||||||
|
${openssh}/bin/ssh mrmanager doas install -d -o 0 -g 0 -m 0700 /vm/${vm_name}/persist/containerd/certs.d/harbor.fizz.buzz
|
||||||
|
''
|
||||||
|
+ (lib.concatMapStringsSep "\n" deploy_file [
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.ca.client}/client-ca.crt";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0640";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.keys."${vm_name_to_hostname vm_name}"}/${vm_name_to_hostname vm_name}.crt";
|
||||||
|
name = "kubelet.crt";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0640";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.keys."${vm_name_to_hostname vm_name}"}/${vm_name_to_hostname vm_name}.key";
|
||||||
|
name = "kubelet.key";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0600";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${
|
||||||
|
k8s.client-configs."${vm_name_to_hostname vm_name}"
|
||||||
|
}/${vm_name_to_hostname vm_name}.kubeconfig";
|
||||||
|
name = "kubelet.kubeconfig";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0600";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/keys/kube";
|
||||||
|
file = "${k8s.client-configs.kube-proxy}/kube-proxy.kubeconfig";
|
||||||
|
owner = 10024;
|
||||||
|
group = 10024;
|
||||||
|
mode = "0600";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/containerd/certs.d/docker.io";
|
||||||
|
file = "${./files/containerd/docker.io/hosts.toml}";
|
||||||
|
name = "hosts.toml";
|
||||||
|
owner = 0;
|
||||||
|
group = 0;
|
||||||
|
mode = "0600";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
dest_dir = "/vm/${vm_name}/persist/containerd/certs.d/harbor.fizz.buzz";
|
||||||
|
file = "${./files/containerd/harbor.fizz.buzz/hosts.toml}";
|
||||||
|
name = "hosts.toml";
|
||||||
|
owner = 0;
|
||||||
|
group = 0;
|
||||||
|
mode = "0600";
|
||||||
|
}
|
||||||
|
])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
trust_ssh_key =
|
||||||
|
{
|
||||||
|
public_key,
|
||||||
|
destination,
|
||||||
|
owner,
|
||||||
|
group,
|
||||||
|
mode,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
public_key_name = builtins.baseNameOf public_key;
|
||||||
|
public_key_contents = builtins.readFile public_key;
|
||||||
|
trimmed = lib.strings.trim public_key_contents;
|
||||||
|
escaped = lib.strings.escapeShellArg trimmed;
|
||||||
|
in
|
||||||
|
''
|
||||||
|
##
|
||||||
|
## trust ${public_key_name} in ${destination}
|
||||||
|
##
|
||||||
|
if ! ${openssh}/bin/ssh mrmanager doas grep -q "${escaped}" "${destination}"; then
|
||||||
|
${openssh}/bin/ssh mrmanager doas tee -a "${destination}" <<<"$(cat ${public_key})"
|
||||||
|
${openssh}/bin/ssh mrmanager doas chown "${owner}:${group}" "${destination}"
|
||||||
|
${openssh}/bin/ssh mrmanager doas chmod "${mode}" "${destination}"
|
||||||
|
else
|
||||||
|
echo "${public_key_name} is already trusted in ${destination}"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
create_pv_dir =
|
||||||
|
{
|
||||||
|
path,
|
||||||
|
owner,
|
||||||
|
group,
|
||||||
|
mode,
|
||||||
|
}:
|
||||||
|
''
|
||||||
|
##
|
||||||
|
## create pv directory ${path}
|
||||||
|
##
|
||||||
|
${openssh}/bin/ssh mrmanager doas install -d -o "${owner}" -g "${group}" -m "${mode}" "/nk8spv/${path}"
|
||||||
|
'';
|
||||||
|
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
|
name = "deploy-script";
|
||||||
|
nativeBuildInputs = [ ];
|
||||||
|
buildInputs = [ ];
|
||||||
|
|
||||||
|
unpackPhase = "true";
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
cp ${deploy_script} "$out"
|
||||||
|
'';
|
||||||
|
})
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user