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

View File

@@ -1,13 +1,25 @@
# 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
etcdNodes = {
k0-0 = "10.1.8.50";
k0-1 = "10.1.8.51";
k0-2 = "10.1.8.52";
};
master = {
node.name = "k0-0";
node.address = "10.1.8.50";
features.k8s.master.enable = true;
features.k8s.nodes = nodes;
features.k8s = {
host.name = "k0-0";
host.address = "10.1.8.50";
master.enable = true;
nodes = nodes;
etcdCluster = {
enable = true;
existing = true;
nodes = etcdNodes;
};
};
services.kubernetes.kubelet.unschedulable = true;
imports = [ ./cluster.nix ./hw/k0-0.nix ];
};
@@ -19,13 +31,24 @@ let
mkNode = x: {
"${x.name}" =
lib.mkMerge [
{
node = x;
imports = [ ./cluster.nix (./hw + "/${x.name}.nix") ];
};
features.k8s.host = x;
}
(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
builtins.foldl' (a: x: a // mkNode x) {
"${master.node.name}" = master;
"${master.features.k8s.host.name}" = master;
} nodes