diff --git a/tests/e2e/tailscale/Vagrantfile b/tests/e2e/tailscale/Vagrantfile index 640ced9c6183..725891e97024 100644 --- a/tests/e2e/tailscale/Vagrantfile +++ b/tests/e2e/tailscale/Vagrantfile @@ -1,8 +1,8 @@ ENV['VAGRANT_NO_PARALLEL'] = 'no' NODE_ROLES = (ENV['E2E_NODE_ROLES'] || - ["server-0", "agent-0" ]) + ["server-0", "agent-0", "agent-1" ]) NODE_BOXES = (ENV['E2E_NODE_BOXES'] || - ['generic/ubuntu2310', 'generic/ubuntu2310']) + ['generic/ubuntu2310', 'generic/ubuntu2310', 'generic/ubuntu2310']) GITHUB_BRANCH = (ENV['E2E_GITHUB_BRANCH'] || "master") RELEASE_VERSION = (ENV['E2E_RELEASE_VERSION'] || "") GOCOVER = (ENV['E2E_GOCOVER'] || "") @@ -45,13 +45,25 @@ def provision(vm, roles, role_num, node_num) end end if roles.include?("agent") + vpn_auth = nil + vpn_auth_method = nil + auth_info = "name=tailscale,joinKey=#{TAILSCALE_KEY}" + if role_num == 0 + vpn_auth_method = "vpn-auth" + vpn_auth = auth_info + else + vpn_auth_method = "vpn-auth-file" + File.write("./vpn-auth-file", auth_info) + vm.provision "file", source: "./vpn-auth-file", destination: "/home/vagrant/vpn-auth-file" + vpn_auth = "/home/vagrant/vpn-auth-file" + end vm.provision :k3s, run: 'once' do |k3s| k3s.config_mode = '0644' # side-step https://github.com/k3s-io/k3s/issues/4321 k3s.args = "agent " k3s.config = <<~YAML server: https://TAILSCALEIP:6443 token: vagrant - vpn-auth: "name=tailscale,joinKey=#{TAILSCALE_KEY}" + #{vpn_auth_method}: #{vpn_auth} YAML k3s.env = ["K3S_KUBECONFIG_MODE=0644", "INSTALL_K3S_SKIP_START=true", install_type] end diff --git a/tests/e2e/tailscale/tailscale_test.go b/tests/e2e/tailscale/tailscale_test.go index 9314cdef4e7b..576be7dab219 100644 --- a/tests/e2e/tailscale/tailscale_test.go +++ b/tests/e2e/tailscale/tailscale_test.go @@ -14,7 +14,7 @@ import ( // Valid nodeOS: generic/ubuntu2310, opensuse/Leap-15.3.x86_64 var nodeOS = flag.String("nodeOS", "generic/ubuntu2310", "VM operating system") var serverCount = flag.Int("serverCount", 1, "number of server nodes") -var agentCount = flag.Int("agentCount", 1, "number of agent nodes") +var agentCount = flag.Int("agentCount", 2, "number of agent nodes") var ci = flag.Bool("ci", false, "running on CI") var local = flag.Bool("local", false, "deploy a locally built K3s binary") @@ -82,6 +82,7 @@ var _ = Describe("Verify Tailscale Configuration", Ordered, func() { Eventually(func(g Gomega) { nodes, err := e2e.ParseNodes(kubeConfigFile, false) g.Expect(err).NotTo(HaveOccurred()) + g.Expect(len(nodes)).To(Equal(*agentCount + *serverCount)) for _, node := range nodes { g.Expect(node.Status).Should(Equal("Ready")) } diff --git a/tests/e2e/testutils.go b/tests/e2e/testutils.go index 03035af67daf..8a550da19e95 100644 --- a/tests/e2e/testutils.go +++ b/tests/e2e/testutils.go @@ -121,6 +121,7 @@ func CreateCluster(nodeOS string, serverCount, agentCount int) ([]string, []stri errg, _ := errgroup.WithContext(context.Background()) for _, node := range append(serverNodeNames[1:], agentNodeNames...) { cmd := fmt.Sprintf(`%s %s vagrant up %s &>> vagrant.log`, nodeEnvs, testOptions, node) + fmt.Println(cmd) errg.Go(func() error { if _, err := RunCommand(cmd); err != nil { return newNodeError(cmd, node, err)