1 import ../make-test-python.nix ({ pkgs, lib, rke2, ... }:
3 pauseImage = pkgs.dockerTools.streamLayeredImage {
4 name = "test.local/pause";
6 contents = pkgs.buildEnv {
7 name = "rke2-pause-image-env";
8 paths = with pkgs; [ tini (hiPrio coreutils) busybox ];
10 config.Entrypoint = [ "/bin/tini" "--" "/bin/sleep" "inf" ];
12 testPodYaml = pkgs.writeText "test.yaml" ''
20 image: test.local/pause:local
21 imagePullPolicy: Never
22 command: ["sh", "-c", "sleep inf"]
26 name = "${rke2.name}-single-node";
27 meta.maintainers = rke2.meta.maintainers;
29 nodes.machine = { pkgs, ... }: {
30 networking.firewall.enable = false;
31 networking.useDHCP = false;
32 networking.defaultGateway = "192.168.1.1";
33 networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkForce [
34 { address = "192.168.1.1"; prefixLength = 24; }
37 virtualisation.memorySize = 1536;
38 virtualisation.diskSize = 4096;
44 nodeIP = "192.168.1.1";
57 kubectl = "${pkgs.kubectl}/bin/kubectl --kubeconfig=/etc/rancher/rke2/rke2.yaml";
58 ctr = "${pkgs.containerd}/bin/ctr -a /run/k3s/containerd/containerd.sock";
62 machine.wait_for_unit("rke2")
63 machine.succeed("${kubectl} cluster-info")
64 machine.wait_until_succeeds(
65 "${pauseImage} | ${ctr} -n k8s.io image import -"
68 machine.wait_until_succeeds("${kubectl} get serviceaccount default")
69 machine.succeed("${kubectl} apply -f ${testPodYaml}")
70 machine.succeed("${kubectl} wait --for 'condition=Ready' pod/test")
71 machine.succeed("${kubectl} delete -f ${testPodYaml}")