1 # Tests whether container images are imported and auto deploying manifests work
2 import ../make-test-python.nix (
10 pauseImageEnv = pkgs.buildEnv {
11 name = "k3s-pause-image-env";
18 pauseImage = pkgs.dockerTools.buildImage {
19 name = "test.local/pause";
21 copyToRoot = pauseImageEnv;
29 helloImage = pkgs.dockerTools.buildImage {
30 name = "test.local/hello";
32 copyToRoot = pkgs.hello;
33 config.Entrypoint = [ "${pkgs.hello}/bin/hello" ];
37 name = "${k3s.name}-auto-deploy";
42 environment.systemPackages = [ k3s ];
44 # k3s uses enough resources the default vm fails.
45 virtualisation.memorySize = 1536;
46 virtualisation.diskSize = 4096;
48 services.k3s.enable = true;
49 services.k3s.role = "server";
50 services.k3s.package = k3s;
51 # Slightly reduce resource usage
52 services.k3s.extraFlags = [
54 "--disable local-storage"
55 "--disable metrics-server"
58 "--pause-image test.local/pause:local"
60 services.k3s.images = [
64 services.k3s.manifests = {
70 metadata.name = "absent";
75 target = "foo-namespace.yaml";
79 metadata.name = "foo";
84 apiVersion = "batch/v1";
86 metadata.name = "hello";
92 image = "test.local/hello:local";
95 restartPolicy = "OnFailure";
105 machine.wait_for_unit("k3s")
106 # check existence of the manifest files
107 machine.fail("ls /var/lib/rancher/k3s/server/manifests/absent.yaml")
108 machine.succeed("ls /var/lib/rancher/k3s/server/manifests/foo-namespace.yaml")
109 machine.succeed("ls /var/lib/rancher/k3s/server/manifests/hello.yaml")
111 # check if container images got imported
112 machine.wait_until_succeeds("crictl img | grep 'test\.local/pause'")
113 machine.wait_until_succeeds("crictl img | grep 'test\.local/hello'")
115 # check if resources of manifests got created
116 machine.wait_until_succeeds("kubectl get ns foo")
117 machine.wait_until_succeeds("kubectl wait --for=condition=complete job/hello")
118 machine.fail("kubectl get ns absent")
123 meta.maintainers = lib.teams.k3s.members;