diff options
author | Jairo Llopis <yajo.sk8@gmail.com> | 2022-08-30 09:27:29 +0100 |
---|---|---|
committer | Jairo Llopis <yajo.sk8@gmail.com> | 2022-08-30 09:27:29 +0100 |
commit | 60e0d3d73670ef8ddca24aa546a40283e3838e69 (patch) | |
tree | 47043bb0987cf17773c3eac8a59e7fb1e8f6844d /nixos/tests | |
parent | 4cd8b7633a30cf4db616beede18844278d021a65 (diff) |
k3s: streamline HA setup
- Replace misleading docs. - Add new assertions to let configurations make more sense. - Add clusterInit flag. - Add some more docs about HA and non-HA modes setup. - Improve multi-node tests for HA mode. Fix https://github.com/NixOS/nixpkgs/issues/182085
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/k3s/multi-node.nix | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/nixos/tests/k3s/multi-node.nix b/nixos/tests/k3s/multi-node.nix index afb8c78f2339e..ae9609fbccc9f 100644 --- a/nixos/tests/k3s/multi-node.nix +++ b/nixos/tests/k3s/multi-node.nix @@ -53,9 +53,10 @@ import ../make-test-python.nix ({ pkgs, ... }: enable = true; role = "server"; package = pkgs.k3s; + clusterInit = true; extraFlags = "--no-deploy coredns,servicelb,traefik,local-storage,metrics-server --pause-image test.local/pause:local --node-ip 192.168.1.1"; }; - networking.firewall.allowedTCPPorts = [ 6443 ]; + networking.firewall.allowedTCPPorts = [ 2379 2380 6443 ]; networking.firewall.allowedUDPPorts = [ 8472 ]; networking.firewall.trustedInterfaces = [ "flannel.1" ]; networking.useDHCP = false; @@ -65,6 +66,28 @@ import ../make-test-python.nix ({ pkgs, ... }: ]; }; + server2 = { pkgs, ... }: { + environment.systemPackages = with pkgs; [ gzip jq ]; + virtualisation.memorySize = 1536; + virtualisation.diskSize = 4096; + + services.k3s = { + inherit tokenFile; + enable = true; + serverAddr = "https://192.168.1.1:6443"; + clusterInit = false; + extraFlags = "--no-deploy coredns,servicelb,traefik,local-storage,metrics-server --pause-image test.local/pause:local --node-ip 192.168.1.3"; + }; + networking.firewall.allowedTCPPorts = [ 2379 2380 6443 ]; + networking.firewall.allowedUDPPorts = [ 8472 ]; + networking.firewall.trustedInterfaces = [ "flannel.1" ]; + networking.useDHCP = false; + networking.defaultGateway = "192.168.1.3"; + networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkForce [ + { address = "192.168.1.3"; prefixLength = 24; } + ]; + }; + agent = { pkgs, ... }: { virtualisation.memorySize = 1024; virtualisation.diskSize = 2048; @@ -72,7 +95,7 @@ import ../make-test-python.nix ({ pkgs, ... }: inherit tokenFile; enable = true; role = "agent"; - serverAddr = "https://192.168.1.1:6443"; + serverAddr = "https://192.168.1.3:6443"; extraFlags = "--pause-image test.local/pause:local --node-ip 192.168.1.2"; }; networking.firewall.allowedTCPPorts = [ 6443 ]; @@ -91,9 +114,9 @@ import ../make-test-python.nix ({ pkgs, ... }: }; testScript = '' - start_all() - machines = [server, agent] + machines = [server, server2, agent] for m in machines: + m.start() m.wait_for_unit("k3s") # wait for the agent to show up |