Update k0 to multi etcd

This commit is contained in:
Jonas Juselius
2021-09-22 21:05:44 +02:00
parent bd426750ec
commit 35bcff9d6f
2 changed files with 54 additions and 22 deletions

View File

@@ -1,7 +1,7 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
with lib; with lib;
let let
cfg = config.node; cfg = config.features.k8s.host;
mkSANs = host: [ mkSANs = host: [
host.name host.name
@@ -91,20 +91,29 @@ let
address = cfg.address; address = cfg.address;
}; };
fileSystems = {
"/vol/local-storage/vol1" = {
device = "/vol/vol1";
options = [ "bind" ];
};
"/vol/local-storage/vol2" = {
device = "/vol/vol2";
options = [ "bind" ];
};
};
}; };
in { in {
options.node = { # options.node = {
address = mkOption { # address = mkOption {
type = types.str; # type = types.str;
default = null; # default = null;
}; # };
name = mkOption { # name = mkOption {
type = types.str; # type = types.str;
default = null; # default = null;
}; # };
# };
};
config = configuration; config = configuration;

View File

@@ -1,13 +1,25 @@
# Pin the deployment package-set to a specific version of nixpkgs # Pin the deployment package-set to a specific version of nixpkgs
# with import <nixpkgs> {}; # with import ../nixos-21.05.nix {};
with import ../nixos-21.05.nix {}; with import <nixpkgs> {};
let let
etcdNodes = {
k0-0 = "10.1.8.50";
k0-1 = "10.1.8.51";
k0-2 = "10.1.8.52";
};
master = { master = {
node.name = "k0-0"; features.k8s = {
node.address = "10.1.8.50"; host.name = "k0-0";
features.k8s.master.enable = true; host.address = "10.1.8.50";
features.k8s.nodes = nodes; master.enable = true;
nodes = nodes;
etcdCluster = {
enable = true;
existing = true;
nodes = etcdNodes;
};
};
services.kubernetes.kubelet.unschedulable = true; services.kubernetes.kubelet.unschedulable = true;
imports = [ ./cluster.nix ./hw/k0-0.nix ]; imports = [ ./cluster.nix ./hw/k0-0.nix ];
}; };
@@ -19,13 +31,24 @@ let
mkNode = x: { mkNode = x: {
"${x.name}" = "${x.name}" =
lib.mkMerge [
{ {
node = x; features.k8s.host = x;
imports = [ ./cluster.nix (./hw + "/${x.name}.nix") ]; }
}; (if builtins.hasAttr x.name etcdNodes then
{
features.k8s.etcdCluster = {
enable = true;
existing = true;
nodes = etcdNodes;
};
}
else {})
]
// { imports = [ ./cluster.nix (./hw + "/${x.name}.nix") ]; };
}; };
in in
builtins.foldl' (a: x: a // mkNode x) { builtins.foldl' (a: x: a // mkNode x) {
"${master.node.name}" = master; "${master.features.k8s.host.name}" = master;
} nodes } nodes