Commit aa579635 authored by Euan Kemp's avatar Euan Kemp
Browse files

nixos/tests/k3s: wait for default service account in test

This lets us write a slightly simpler test, and more closely matches
actual k8s usage
parent d5b1e257
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -10,20 +10,12 @@ import ../make-test-python.nix ({ pkgs, ... }:
      contents = imageEnv;
      config.Entrypoint = [ "/bin/tini" "--" "/bin/sleep" "inf" ];
    };
    # Don't use the default service account because there's a race where it may
    # not be created yet; make our own instead.
    testPodYaml = pkgs.writeText "test.yml" ''
      apiVersion: v1
      kind: ServiceAccount
      metadata:
        name: test
      ---
      apiVersion: v1
      kind: Pod
      metadata:
        name: test
      spec:
        serviceAccountName: test
        containers:
        - name: test
          image: test.local/pause:local
@@ -65,13 +57,14 @@ import ../make-test-python.nix ({ pkgs, ... }:
      machine.wait_for_unit("k3s")
      machine.succeed("k3s kubectl cluster-info")
      machine.fail("sudo -u noprivs k3s kubectl cluster-info")
      # FIXME: this fails with the current nixos kernel config; once it passes, we should uncomment it
      # machine.succeed("k3s check-config")
      machine.succeed("k3s check-config")

      machine.succeed(
          "${pauseImage} | k3s ctr image import -"
      )

      # Also wait for our service account to show up; it takes a sec
      machine.wait_until_succeeds("k3s kubectl get serviceaccount default")
      machine.succeed("k3s kubectl apply -f ${testPodYaml}")
      machine.succeed("k3s kubectl wait --for 'condition=Ready' pod/test")
      machine.succeed("k3s kubectl delete -f ${testPodYaml}")