Skip to content

Commit

Permalink
Formats with nixfmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjameswhitman committed Jan 10, 2025
1 parent 2b4a024 commit 5edd776
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 127 deletions.
13 changes: 6 additions & 7 deletions machines/hello.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
lib,
pkgs,
...
}: {
users.groups.admin = {};
}:
{
users.groups.admin = { };
users.users = {
admin = {
isNormalUser = true;
extraGroups = ["wheel"];
extraGroups = [ "wheel" ];
password = "admin";
group = "admin";
};
Expand All @@ -28,10 +29,8 @@
settings.PasswordAuthentication = true;
};

networking.firewall.allowedTCPPorts = [22];
environment.systemPackages = with pkgs; [
htop
];
networking.firewall.allowedTCPPorts = [ 22 ];
environment.systemPackages = with pkgs; [ htop ];

system.stateVersion = "24.05";
}
13 changes: 8 additions & 5 deletions tests/hello.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{pkgs, ...}: {
{ pkgs, ... }:
{
name = "hello";
nodes = {
machine1 = {pkgs, ...}: {
imports = [../machines/hello.nix];
environment.systemPackages = [pkgs.hello];
};
machine1 =
{ pkgs, ... }:
{
imports = [ ../machines/hello.nix ];
environment.systemPackages = [ pkgs.hello ];
};
};
testScript = ''
start_all()
Expand Down
234 changes: 119 additions & 115 deletions tests/k3s-multi-node.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Inspired by: https://github.com/NixOS/nixpkgs/blob/b1ea4a36d6f1bb62734bce3483994df69910e6d9/nixos/tests/k3s/multi-node.nix#
{
pkgs,
lib,
...
}: let
{ pkgs, lib, ... }:
let
imageEnv = pkgs.buildEnv {
name = "k3s-pause-image-env";
paths = with pkgs; [
Expand Down Expand Up @@ -51,125 +48,132 @@
command: ["socat", "TCP4-LISTEN:8000,fork", "EXEC:echo server"]
'';
tokenFile = pkgs.writeText "token" "p@s$w0rd";
in {
in
{
name = "k3s-multi-node";

nodes = {
server = {pkgs, ...}: {
environment.systemPackages = with pkgs; [
gzip
jq
];
# k3s uses enough resources the default vm fails.
virtualisation.memorySize = 1536;
virtualisation.diskSize = 4096;

services.k3s = {
inherit tokenFile;
enable = true;
role = "server";
clusterInit = true;
extraFlags = lib.strings.concatStringsSep " " [
"--disable coredns"
"--disable local-storage"
"--disable metrics-server"
"--disable servicelb"
"--disable traefik"
"--node-ip 192.168.1.1"
"--pause-image test.local/pause:local"
server =
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
gzip
jq
];
# k3s uses enough resources the default vm fails.
virtualisation.memorySize = 1536;
virtualisation.diskSize = 4096;

services.k3s = {
inherit tokenFile;
enable = true;
role = "server";
clusterInit = true;
extraFlags = lib.strings.concatStringsSep " " [
"--disable coredns"
"--disable local-storage"
"--disable metrics-server"
"--disable servicelb"
"--disable traefik"
"--node-ip 192.168.1.1"
"--pause-image test.local/pause:local"
];
};
networking.firewall.allowedTCPPorts = [
2379
2380
6443
];
networking.firewall.allowedUDPPorts = [ 8472 ];
networking.firewall.trustedInterfaces = [ "flannel.1" ];
networking.useDHCP = false;
networking.defaultGateway = "192.168.1.1";
networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkForce [
{
address = "192.168.1.1";
prefixLength = 24;
}
];
};
networking.firewall.allowedTCPPorts = [
2379
2380
6443
];
networking.firewall.allowedUDPPorts = [8472];
networking.firewall.trustedInterfaces = ["flannel.1"];
networking.useDHCP = false;
networking.defaultGateway = "192.168.1.1";
networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkForce [
{
address = "192.168.1.1";
prefixLength = 24;
}
];
};

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 = builtins.toString [
"--disable"
"coredns"
"--disable"
"local-storage"
"--disable"
"metrics-server"
"--disable"
"servicelb"
"--disable"
"traefik"
"--node-ip"
"192.168.1.3"
"--pause-image"
"test.local/pause:local"

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 = builtins.toString [
"--disable"
"coredns"
"--disable"
"local-storage"
"--disable"
"metrics-server"
"--disable"
"servicelb"
"--disable"
"traefik"
"--node-ip"
"192.168.1.3"
"--pause-image"
"test.local/pause:local"
];
};
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;
}
];
};
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;
services.k3s = {
inherit tokenFile;
enable = true;
role = "agent";
serverAddr = "https://192.168.1.3:6443";
extraFlags = lib.concatStringsSep " " [
"--pause-image"
"test.local/pause:local"
"--node-ip"
"192.168.1.2"

agent =
{ pkgs, ... }:
{
virtualisation.memorySize = 1024;
virtualisation.diskSize = 2048;
services.k3s = {
inherit tokenFile;
enable = true;
role = "agent";
serverAddr = "https://192.168.1.3:6443";
extraFlags = lib.concatStringsSep " " [
"--pause-image"
"test.local/pause:local"
"--node-ip"
"192.168.1.2"
];
};
networking.firewall.allowedTCPPorts = [ 6443 ];
networking.firewall.allowedUDPPorts = [ 8472 ];
networking.firewall.trustedInterfaces = [ "flannel.1" ];
networking.useDHCP = false;
networking.defaultGateway = "192.168.1.2";
networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkForce [
{
address = "192.168.1.2";
prefixLength = 24;
}
];
};
networking.firewall.allowedTCPPorts = [6443];
networking.firewall.allowedUDPPorts = [8472];
networking.firewall.trustedInterfaces = ["flannel.1"];
networking.useDHCP = false;
networking.defaultGateway = "192.168.1.2";
networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkForce [
{
address = "192.168.1.2";
prefixLength = 24;
}
];
};
};

testScript = ''
Expand Down

0 comments on commit 5edd776

Please sign in to comment.