mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
E2E Split Server Test (#5286)
* Simplify role in existing tests * Update other tests to output vagrant log on failure * go test for split server Signed-off-by: Derek Nola <derek.nola@suse.com>
This commit is contained in:
parent
3cebde924b
commit
4eed971289
13
tests/e2e/secretsencryption/Vagrantfile
vendored
13
tests/e2e/secretsencryption/Vagrantfile
vendored
@ -11,9 +11,9 @@ NODE_MEMORY = (ENV['NODE_MEMORY'] || 1024).to_i
|
||||
NETWORK_PREFIX = "10.10.10"
|
||||
install_type = ""
|
||||
|
||||
def provision(vm, roles, role_num, node_num)
|
||||
def provision(vm, role, role_num, node_num)
|
||||
vm.box = NODE_BOXES[node_num]
|
||||
vm.hostname = "#{roles[0]}-#{role_num}"
|
||||
vm.hostname = role
|
||||
# An expanded netmask is required to allow VM<-->VM communication, virtualbox defaults to /32
|
||||
vm.network "private_network", ip: "#{NETWORK_PREFIX}.#{100+node_num}", netmask: "255.255.255.0"
|
||||
|
||||
@ -31,13 +31,13 @@ def provision(vm, roles, role_num, node_num)
|
||||
end
|
||||
vm.provision "shell", inline: "ping -c 2 k3s.io"
|
||||
|
||||
if roles.include?("server") && role_num == 0
|
||||
if role.include?("server") && role_num == 0
|
||||
vm.provision 'k3s-install', type: 'k3s', run: 'once' do |k3s|
|
||||
k3s.args = %W[server --cluster-init --node-external-ip=#{NETWORK_PREFIX}.100 --flannel-iface=eth1 --secrets-encryption]
|
||||
k3s.env = %W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant #{install_type}]
|
||||
k3s.config_mode = '0644' # side-step https://github.com/k3s-io/k3s/issues/4321
|
||||
end
|
||||
elsif roles.include?("server") && role_num != 0
|
||||
elsif role.include?("server") && role_num != 0
|
||||
vm.provision 'k3s-install', type: 'k3s', run: 'once' do |k3s|
|
||||
k3s.args = %W[server --server https://#{NETWORK_PREFIX}.100:6443 --flannel-iface=eth1 --secrets-encryption]
|
||||
k3s.env = %W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant #{install_type}]
|
||||
@ -72,10 +72,9 @@ Vagrant.configure("2") do |config|
|
||||
# over the node roles themselves
|
||||
NODE_ROLES.length.times do |i|
|
||||
name = NODE_ROLES[i]
|
||||
role_num = name.split("-", -1).pop.to_i
|
||||
config.vm.define name do |node|
|
||||
roles = name.split("-", -1)
|
||||
role_num = roles.pop.to_i
|
||||
provision(node.vm, roles, role_num, i)
|
||||
provision(node.vm, name, role_num, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
113
tests/e2e/splitserver/Vagrantfile
vendored
Normal file
113
tests/e2e/splitserver/Vagrantfile
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
ENV['VAGRANT_NO_PARALLEL'] = 'no'
|
||||
NODE_ROLES = (ENV['E2E_NODE_ROLES'] ||
|
||||
["server-etcd-0", "server-cp-0", "server-cp-1", "agent-0"])
|
||||
NODE_BOXES = (ENV['E2E_NODE_BOXES'] ||
|
||||
['generic/ubuntu2004', 'generic/ubuntu2004', 'generic/ubuntu2004', 'generic/ubuntu2004', 'generic/ubuntu2004'])
|
||||
GITHUB_BRANCH = (ENV['E2E_GITHUB_BRANCH'] || "master")
|
||||
RELEASE_VERSION = (ENV['E2E_RELEASE_VERSION'] || "")
|
||||
NODE_CPUS = (ENV['E2E_NODE_CPUS'] || 2).to_i
|
||||
NODE_MEMORY = (ENV['E2E_NODE_MEMORY'] || 1024).to_i
|
||||
# Virtualbox >= 6.1.28 require `/etc/vbox/network.conf` for expanded private networks
|
||||
NETWORK_PREFIX = "10.10.10"
|
||||
install_type = ""
|
||||
|
||||
def provision(vm, role, role_num, node_num)
|
||||
vm.box = NODE_BOXES[node_num]
|
||||
vm.hostname = role
|
||||
# An expanded netmask is required to allow VM<-->VM communication, virtualbox defaults to /32
|
||||
vm.network "private_network", ip: "#{NETWORK_PREFIX}.#{100+node_num}", netmask: "255.255.255.0"
|
||||
|
||||
vagrant_defaults = '../vagrantdefaults.rb'
|
||||
load vagrant_defaults if File.exists?(vagrant_defaults)
|
||||
|
||||
defaultOSConfigure(vm)
|
||||
|
||||
if !RELEASE_VERSION.empty?
|
||||
install_type = "INSTALL_K3S_VERSION=#{RELEASE_VERSION}"
|
||||
else
|
||||
# Grabs the last 5 commit SHA's from the given branch, then purges any commits that do not have a passing CI build
|
||||
# MicroOS requires it not be in a /tmp/ or other root system folder
|
||||
vm.provision "Acquire latest commit", type: "shell", path: "../scripts/latest_commit.sh", args: [GITHUB_BRANCH, "/home/vagrant/k3s_commits"]
|
||||
install_type = "INSTALL_K3S_COMMIT=$(head\ -n\ 1\ /home/vagrant/k3s_commits)"
|
||||
end
|
||||
vm.provision "ping k3s.io", type: "shell", inline: "ping -c 2 k3s.io"
|
||||
|
||||
if node_num == 0 && !role.include?("server") && !role.include?("etcd")
|
||||
puts "first node must be a etcd server"
|
||||
abort
|
||||
elsif role.include?("server") && role.include?("etcd") && role_num == 0
|
||||
vm.provision 'k3s-install', type: 'k3s', run: 'once' do |k3s|
|
||||
k3s.args = "server"
|
||||
k3s.config = <<~YAML
|
||||
cluster-init: true
|
||||
note-external-ip: #{NETWORK_PREFIX}.100
|
||||
flannel-iface: eth1
|
||||
disable-apiserver: true
|
||||
disable-controller-manager: true
|
||||
disable-scheduler: true
|
||||
YAML
|
||||
k3s.args = "server --cluster-init --disable-apiserver --disable-controller-manager --disable-scheduler --node-external-ip=#{NETWORK_PREFIX}.100 --flannel-iface=eth1"
|
||||
k3s.env = %W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant #{install_type}]
|
||||
k3s.config_mode = '0644' # side-step https://github.com/k3s-io/k3s/issues/4321
|
||||
end
|
||||
elsif role.include?("server") && role.include?("etcd") && role_num != 0
|
||||
vm.provision 'k3s-install', type: 'k3s', run: 'once' do |k3s|
|
||||
k3s.args = "server"
|
||||
k3s.config = <<~YAML
|
||||
server: https://#{NETWORK_PREFIX}.100:6443
|
||||
flannel-iface: eth1
|
||||
disable-apiserver: true
|
||||
disable-controller-manager: true
|
||||
disable-scheduler: true
|
||||
YAML
|
||||
k3s.env = %W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant #{install_type}]
|
||||
k3s.config_mode = '0644' # side-step https://github.com/k3s-io/k3s/issues/4321
|
||||
end
|
||||
elsif role.include?("server") && role.include?("cp")
|
||||
vm.provision 'k3s-install', type: 'k3s', run: 'once' do |k3s|
|
||||
k3s.args = "server --disable-etcd --server https://#{NETWORK_PREFIX}.100:6443 --flannel-iface=eth1"
|
||||
k3s.env = %W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant #{install_type}]
|
||||
k3s.config_mode = '0644' # side-step https://github.com/k3s-io/k3s/issues/4321
|
||||
end
|
||||
end
|
||||
if role.include?("agent")
|
||||
vm.provision 'k3s-install', type: 'k3s', run: 'once' do |k3s|
|
||||
k3s.args = %W[agent --server https://#{NETWORK_PREFIX}.101:6443 --flannel-iface=eth1]
|
||||
k3s.env = %W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant #{install_type}]
|
||||
k3s.config_mode = '0644' # side-step https://github.com/k3s-io/k3s/issues/4321
|
||||
end
|
||||
end
|
||||
if vm.box.include?("microos")
|
||||
vm.provision 'k3s-reload', type: 'reload', run: 'once'
|
||||
end
|
||||
end
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vagrant.plugins = ["vagrant-k3s", "vagrant-reload"]
|
||||
# Default provider is libvirt, virtualbox is only provided as a backup
|
||||
config.vm.provider "libvirt" do |v|
|
||||
v.cpus = NODE_CPUS
|
||||
v.memory = NODE_MEMORY
|
||||
end
|
||||
config.vm.provider "virtualbox" do |v|
|
||||
v.cpus = NODE_CPUS
|
||||
v.memory = NODE_MEMORY
|
||||
end
|
||||
|
||||
if NODE_ROLES.kind_of?(String)
|
||||
NODE_ROLES = NODE_ROLES.split(" ", -1)
|
||||
end
|
||||
if NODE_BOXES.kind_of?(String)
|
||||
NODE_BOXES = NODE_BOXES.split(" ", -1)
|
||||
end
|
||||
|
||||
# Must iterate on the index, vagrant does not understand iterating
|
||||
# over the node roles themselves
|
||||
NODE_ROLES.length.times do |i|
|
||||
name = NODE_ROLES[i]
|
||||
role_num = name.split("-", -1).pop.to_i
|
||||
config.vm.define name do |node|
|
||||
provision(node.vm, name, role_num, i)
|
||||
end
|
||||
end
|
||||
end
|
263
tests/e2e/splitserver/splitserver_test.go
Normal file
263
tests/e2e/splitserver/splitserver_test.go
Normal file
@ -0,0 +1,263 @@
|
||||
package validatecluster
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/k3s-io/k3s/tests/e2e"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
// Valid nodeOS: generic/ubuntu2004, opensuse/Leap-15.3.x86_64, dweomer/microos.amd64
|
||||
var nodeOS = flag.String("nodeOS", "generic/ubuntu2004", "VM operating system")
|
||||
var etcdCount = flag.Int("etcdCount", 1, "number of server nodes only deploying etcd")
|
||||
var controlPlaneCount = flag.Int("controlPlaneCount", 1, "number of server nodes acting as control plane")
|
||||
var agentCount = flag.Int("agentCount", 1, "number of agent nodes")
|
||||
|
||||
// Environment Variables Info:
|
||||
// E2E_RELEASE_VERSION=v1.23.1+k3s2 or nil for latest commit from master
|
||||
|
||||
func createSplitCluster(nodeOS string, etcdCount, controlPlaneCount, agentCount int) ([]string, []string, []string, error) {
|
||||
etcdNodeNames := make([]string, etcdCount)
|
||||
for i := 0; i < etcdCount; i++ {
|
||||
etcdNodeNames[i] = "server-etcd-" + strconv.Itoa(i)
|
||||
}
|
||||
cpNodeNames := make([]string, controlPlaneCount)
|
||||
for i := 0; i < controlPlaneCount; i++ {
|
||||
cpNodeNames[i] = "server-cp-" + strconv.Itoa(i)
|
||||
}
|
||||
agentNodeNames := make([]string, agentCount)
|
||||
for i := 0; i < agentCount; i++ {
|
||||
agentNodeNames[i] = "agent-" + strconv.Itoa(i)
|
||||
}
|
||||
nodeRoles := strings.Join(etcdNodeNames, " ") + " " + strings.Join(cpNodeNames, " ") + " " + strings.Join(agentNodeNames, " ")
|
||||
|
||||
nodeRoles = strings.TrimSpace(nodeRoles)
|
||||
nodeBoxes := strings.Repeat(nodeOS+" ", etcdCount+controlPlaneCount+agentCount)
|
||||
nodeBoxes = strings.TrimSpace(nodeBoxes)
|
||||
|
||||
var testOptions string
|
||||
for _, env := range os.Environ() {
|
||||
if strings.HasPrefix(env, "E2E_") {
|
||||
testOptions += " " + env
|
||||
}
|
||||
}
|
||||
|
||||
cmd := fmt.Sprintf(`E2E_NODE_ROLES="%s" E2E_NODE_BOXES="%s" %s vagrant up &> vagrant.log`, nodeRoles, nodeBoxes, testOptions)
|
||||
fmt.Println(cmd)
|
||||
if _, err := e2e.RunCommand(cmd); err != nil {
|
||||
fmt.Println("Error Creating Cluster", err)
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
return etcdNodeNames, cpNodeNames, agentNodeNames, nil
|
||||
}
|
||||
func Test_E2ESplitServer(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
flag.Parse()
|
||||
RunSpecs(t, "Split Server Test Suite")
|
||||
}
|
||||
|
||||
var (
|
||||
kubeConfigFile string
|
||||
etcdNodeNames []string
|
||||
cpNodeNames []string
|
||||
agentNodeNames []string
|
||||
)
|
||||
|
||||
var _ = Describe("Verify Create", func() {
|
||||
Context("Cluster :", func() {
|
||||
It("Starts up with no issues", func() {
|
||||
var err error
|
||||
etcdNodeNames, cpNodeNames, agentNodeNames, err = createSplitCluster(*nodeOS, *etcdCount, *controlPlaneCount, *agentCount)
|
||||
Expect(err).NotTo(HaveOccurred(), e2e.GetVagrantLog())
|
||||
fmt.Println("CLUSTER CONFIG")
|
||||
fmt.Println("OS:", *nodeOS)
|
||||
fmt.Println("Etcd Server Nodes:", etcdNodeNames)
|
||||
fmt.Println("Control Plane Server Nodes:", cpNodeNames)
|
||||
fmt.Println("Agent Nodes:", agentNodeNames)
|
||||
kubeConfigFile, err = e2e.GenKubeConfigFile(cpNodeNames[0])
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
It("Checks Node and Pod Status", func() {
|
||||
fmt.Printf("\nFetching node status\n")
|
||||
Eventually(func(g Gomega) {
|
||||
nodes, err := e2e.ParseNodes(kubeConfigFile, false)
|
||||
g.Expect(err).NotTo(HaveOccurred())
|
||||
for _, node := range nodes {
|
||||
g.Expect(node.Status).Should(Equal("Ready"))
|
||||
}
|
||||
}, "420s", "5s").Should(Succeed())
|
||||
_, _ = e2e.ParseNodes(kubeConfigFile, true)
|
||||
|
||||
fmt.Printf("\nFetching Pods status\n")
|
||||
Eventually(func(g Gomega) {
|
||||
pods, err := e2e.ParsePods(kubeConfigFile, false)
|
||||
g.Expect(err).NotTo(HaveOccurred())
|
||||
for _, pod := range pods {
|
||||
if strings.Contains(pod.Name, "helm-install") {
|
||||
g.Expect(pod.Status).Should(Equal("Completed"), pod.Name)
|
||||
} else {
|
||||
g.Expect(pod.Status).Should(Equal("Running"), pod.Name)
|
||||
}
|
||||
}
|
||||
}, "420s", "5s").Should(Succeed())
|
||||
_, _ = e2e.ParsePods(kubeConfigFile, true)
|
||||
})
|
||||
|
||||
It("Verifies ClusterIP Service", func() {
|
||||
_, err := e2e.DeployWorkload("clusterip.yaml", kubeConfigFile, false)
|
||||
Expect(err).NotTo(HaveOccurred(), "Cluster IP manifest not deployed")
|
||||
|
||||
Eventually(func(g Gomega) {
|
||||
cmd := "kubectl get pods -o=name -l k8s-app=nginx-app-clusterip --field-selector=status.phase=Running --kubeconfig=" + kubeConfigFile
|
||||
res, err := e2e.RunCommand(cmd)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
g.Expect(res).Should((ContainSubstring("test-clusterip")))
|
||||
}, "240s", "5s").Should(Succeed())
|
||||
|
||||
clusterip, _ := e2e.FetchClusterIP(kubeConfigFile, "nginx-clusterip-svc")
|
||||
cmd := "curl -L --insecure http://" + clusterip + "/name.html"
|
||||
fmt.Println(cmd)
|
||||
for _, nodeName := range cpNodeNames {
|
||||
Eventually(func(g Gomega) {
|
||||
res, err := e2e.RunCmdOnNode(cmd, nodeName)
|
||||
g.Expect(err).NotTo(HaveOccurred())
|
||||
fmt.Println(res)
|
||||
Expect(res).Should(ContainSubstring("test-clusterip"))
|
||||
}, "120s", "10s").Should(Succeed())
|
||||
}
|
||||
})
|
||||
|
||||
It("Verifies NodePort Service", func() {
|
||||
_, err := e2e.DeployWorkload("nodeport.yaml", kubeConfigFile, false)
|
||||
Expect(err).NotTo(HaveOccurred(), "NodePort manifest not deployed")
|
||||
|
||||
for _, nodeName := range cpNodeNames {
|
||||
nodeExternalIP, _ := e2e.FetchNodeExternalIP(nodeName)
|
||||
cmd := "kubectl get service nginx-nodeport-svc --kubeconfig=" + kubeConfigFile + " --output jsonpath=\"{.spec.ports[0].nodePort}\""
|
||||
nodeport, err := e2e.RunCommand(cmd)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Eventually(func(g Gomega) {
|
||||
cmd := "kubectl get pods -o=name -l k8s-app=nginx-app-nodeport --field-selector=status.phase=Running --kubeconfig=" + kubeConfigFile
|
||||
res, err := e2e.RunCommand(cmd)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
g.Expect(res).Should(ContainSubstring("test-nodeport"), "nodeport pod was not created")
|
||||
}, "240s", "5s").Should(Succeed())
|
||||
|
||||
cmd = "curl -L --insecure http://" + nodeExternalIP + ":" + nodeport + "/name.html"
|
||||
fmt.Println(cmd)
|
||||
Eventually(func(g Gomega) {
|
||||
res, err := e2e.RunCommand(cmd)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
fmt.Println(res)
|
||||
g.Expect(res).Should(ContainSubstring("test-nodeport"))
|
||||
}, "240s", "5s").Should(Succeed())
|
||||
}
|
||||
})
|
||||
|
||||
It("Verifies LoadBalancer Service", func() {
|
||||
_, err := e2e.DeployWorkload("loadbalancer.yaml", kubeConfigFile, false)
|
||||
Expect(err).NotTo(HaveOccurred(), "Loadbalancer manifest not deployed")
|
||||
|
||||
for _, nodeName := range cpNodeNames {
|
||||
ip, _ := e2e.FetchNodeExternalIP(nodeName)
|
||||
|
||||
cmd := "kubectl get service nginx-loadbalancer-svc --kubeconfig=" + kubeConfigFile + " --output jsonpath=\"{.spec.ports[0].port}\""
|
||||
port, err := e2e.RunCommand(cmd)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Eventually(func(g Gomega) {
|
||||
cmd := "kubectl get pods -o=name -l k8s-app=nginx-app-loadbalancer --field-selector=status.phase=Running --kubeconfig=" + kubeConfigFile
|
||||
res, err := e2e.RunCommand(cmd)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
g.Expect(res).Should(ContainSubstring("test-loadbalancer"))
|
||||
}, "240s", "5s").Should(Succeed())
|
||||
|
||||
Eventually(func(g Gomega) {
|
||||
cmd = "curl -L --insecure http://" + ip + ":" + port + "/name.html"
|
||||
fmt.Println(cmd)
|
||||
res, err := e2e.RunCommand(cmd)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
fmt.Println(res)
|
||||
g.Expect(res).Should(ContainSubstring("test-loadbalancer"))
|
||||
}, "240s", "5s").Should(Succeed())
|
||||
}
|
||||
})
|
||||
|
||||
It("Verifies Ingress", func() {
|
||||
_, err := e2e.DeployWorkload("ingress.yaml", kubeConfigFile, false)
|
||||
Expect(err).NotTo(HaveOccurred(), "Ingress manifest not deployed")
|
||||
|
||||
for _, nodeName := range cpNodeNames {
|
||||
ip, _ := e2e.FetchNodeExternalIP(nodeName)
|
||||
cmd := "curl --header host:foo1.bar.com" + " http://" + ip + "/name.html"
|
||||
fmt.Println(cmd)
|
||||
|
||||
Eventually(func(g Gomega) {
|
||||
res, err := e2e.RunCommand(cmd)
|
||||
g.Expect(err).NotTo(HaveOccurred())
|
||||
fmt.Println(res)
|
||||
g.Expect(res).Should(ContainSubstring("test-ingress"))
|
||||
}, "240s", "5s").Should(Succeed())
|
||||
}
|
||||
})
|
||||
|
||||
It("Verifies Daemonset", func() {
|
||||
_, err := e2e.DeployWorkload("daemonset.yaml", kubeConfigFile, false)
|
||||
Expect(err).NotTo(HaveOccurred(), "Daemonset manifest not deployed")
|
||||
|
||||
nodes, _ := e2e.ParseNodes(kubeConfigFile, false)
|
||||
pods, _ := e2e.ParsePods(kubeConfigFile, false)
|
||||
|
||||
Eventually(func(g Gomega) {
|
||||
count := e2e.CountOfStringInSlice("test-daemonset", pods)
|
||||
fmt.Println("POD COUNT")
|
||||
fmt.Println(count)
|
||||
fmt.Println("NODE COUNT")
|
||||
fmt.Println(len(nodes))
|
||||
g.Expect(len(nodes)).Should((Equal(count)), "Daemonset pod count does not match node count")
|
||||
}, "420s", "10s").Should(Succeed())
|
||||
})
|
||||
|
||||
It("Verifies dns access", func() {
|
||||
_, err := e2e.DeployWorkload("dnsutils.yaml", kubeConfigFile, false)
|
||||
Expect(err).NotTo(HaveOccurred(), "dnsutils manifest not deployed")
|
||||
|
||||
Eventually(func(g Gomega) {
|
||||
cmd := "kubectl get pods dnsutils --kubeconfig=" + kubeConfigFile
|
||||
res, _ := e2e.RunCommand(cmd)
|
||||
fmt.Println(res)
|
||||
g.Expect(res).Should(ContainSubstring("dnsutils"))
|
||||
}, "420s", "2s").Should(Succeed())
|
||||
|
||||
Eventually(func(g Gomega) {
|
||||
cmd := "kubectl --kubeconfig=" + kubeConfigFile + " exec -i -t dnsutils -- nslookup kubernetes.default"
|
||||
fmt.Println(cmd)
|
||||
res, _ := e2e.RunCommand(cmd)
|
||||
fmt.Println(res)
|
||||
g.Expect(res).Should(ContainSubstring("kubernetes.default.svc.cluster.local"))
|
||||
}, "420s", "2s").Should(Succeed())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
var failed = false
|
||||
var _ = AfterEach(func() {
|
||||
failed = failed || CurrentGinkgoTestDescription().Failed
|
||||
})
|
||||
|
||||
var _ = AfterSuite(func() {
|
||||
if failed {
|
||||
fmt.Println("FAILED!")
|
||||
} else {
|
||||
Expect(e2e.DestroyCluster()).To(Succeed())
|
||||
Expect(os.Remove(kubeConfigFile)).To(Succeed())
|
||||
}
|
||||
})
|
@ -175,7 +175,9 @@ func ParseNodes(kubeConfig string, print bool) ([]Node, error) {
|
||||
Status: fields[1],
|
||||
Roles: fields[2],
|
||||
InternalIP: fields[5],
|
||||
ExternalIP: fields[6],
|
||||
}
|
||||
if len(fields) > 6 {
|
||||
node.ExternalIP = fields[6]
|
||||
}
|
||||
nodes = append(nodes, node)
|
||||
}
|
||||
|
15
tests/e2e/upgradecluster/Vagrantfile
vendored
15
tests/e2e/upgradecluster/Vagrantfile
vendored
@ -11,9 +11,9 @@ NODE_MEMORY = (ENV['NODE_MEMORY'] || 1024).to_i
|
||||
NETWORK_PREFIX = "10.10.10"
|
||||
install_type = ""
|
||||
|
||||
def provision(vm, roles, role_num, node_num)
|
||||
def provision(vm, role, role_num, node_num)
|
||||
vm.box = NODE_BOXES[node_num]
|
||||
vm.hostname = "#{roles[0]}-#{role_num}"
|
||||
vm.hostname = role
|
||||
# An expanded netmask is required to allow VM<-->VM communication, virtualbox defaults to /32
|
||||
vm.network "private_network", ip: "#{NETWORK_PREFIX}.#{100+node_num}", netmask: "255.255.255.0"
|
||||
|
||||
@ -35,20 +35,20 @@ def provision(vm, roles, role_num, node_num)
|
||||
|
||||
vm.provision "shell", inline: "ping -c 2 k3s.io"
|
||||
|
||||
if roles.include?("server") && role_num == 0
|
||||
if role.include?("server") && role_num == 0
|
||||
vm.provision 'k3s-install', type: 'k3s', run: 'once' do |k3s|
|
||||
k3s.args = %W[server --cluster-init --node-external-ip=#{NETWORK_PREFIX}.100 --flannel-iface=eth1]
|
||||
k3s.env = %W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant #{install_type}]
|
||||
k3s.config_mode = '0644' # side-step https://github.com/k3s-io/k3s/issues/4321
|
||||
end
|
||||
elsif roles.include?("server") && role_num != 0
|
||||
elsif role.include?("server") && role_num != 0
|
||||
vm.provision 'k3s-install', type: 'k3s', run: 'once' do |k3s|
|
||||
k3s.args = %W[server --server https://#{NETWORK_PREFIX}.100:6443 --flannel-iface=eth1]
|
||||
k3s.env = %W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant #{install_type}]
|
||||
k3s.config_mode = '0644' # side-step https://github.com/k3s-io/k3s/issues/4321
|
||||
end
|
||||
end
|
||||
if roles.include?("agent")
|
||||
if role.include?("agent")
|
||||
vm.provision 'k3s-install', type: 'k3s', run: 'once' do |k3s|
|
||||
k3s.args = %W[agent --server https://#{NETWORK_PREFIX}.100:6443 --flannel-iface=eth1]
|
||||
k3s.env = %W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant #{install_type}]
|
||||
@ -83,10 +83,9 @@ Vagrant.configure("2") do |config|
|
||||
# over the node roles themselves
|
||||
NODE_ROLES.length.times do |i|
|
||||
name = NODE_ROLES[i]
|
||||
role_num = name.split("-", -1).pop.to_i
|
||||
config.vm.define name do |node|
|
||||
roles = name.split("-", -1)
|
||||
role_num = roles.pop.to_i
|
||||
provision(node.vm, roles, role_num, i)
|
||||
provision(node.vm, name, role_num, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -39,7 +39,7 @@ var _ = Describe("Verify Upgrade", func() {
|
||||
It("Starts up with no issues", func() {
|
||||
var err error
|
||||
serverNodeNames, agentNodeNames, err = e2e.CreateCluster(*nodeOS, *serverCount, *agentCount)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(err).NotTo(HaveOccurred(), e2e.GetVagrantLog())
|
||||
fmt.Println("CLUSTER CONFIG")
|
||||
fmt.Println("OS:", *nodeOS)
|
||||
fmt.Println("Server Nodes:", serverNodeNames)
|
||||
|
15
tests/e2e/validatecluster/Vagrantfile
vendored
15
tests/e2e/validatecluster/Vagrantfile
vendored
@ -13,9 +13,9 @@ NETWORK_PREFIX = "10.10.10"
|
||||
install_type = ""
|
||||
db_type = ""
|
||||
|
||||
def provision(vm, roles, role_num, node_num)
|
||||
def provision(vm, role, role_num, node_num)
|
||||
vm.box = NODE_BOXES[node_num]
|
||||
vm.hostname = "#{roles[0]}-#{role_num}"
|
||||
vm.hostname = role
|
||||
# An expanded netmask is required to allow VM<-->VM communication, virtualbox defaults to /32
|
||||
vm.network "private_network", ip: "#{NETWORK_PREFIX}.#{100+node_num}", netmask: "255.255.255.0"
|
||||
|
||||
@ -34,7 +34,7 @@ def provision(vm, roles, role_num, node_num)
|
||||
end
|
||||
vm.provision "shell", inline: "ping -c 2 k3s.io"
|
||||
|
||||
if roles.include?("server") && role_num == 0
|
||||
if role.include?("server") && role_num == 0
|
||||
if EXTERNAL_DB == "mysql"
|
||||
dockerInstall(vm)
|
||||
vm.provision "shell", inline: "docker run -d -p 3306:3306 --name #{EXTERNAL_DB} -e MYSQL_ROOT_PASSWORD=e2e mysql:5.7"
|
||||
@ -57,7 +57,7 @@ def provision(vm, roles, role_num, node_num)
|
||||
k3s.env = %W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant #{install_type}]
|
||||
k3s.config_mode = '0644' # side-step https://github.com/k3s-io/k3s/issues/4321
|
||||
end
|
||||
elsif roles.include?("server") && role_num != 0
|
||||
elsif role.include?("server") && role_num != 0
|
||||
if EXTERNAL_DB == "mysql"
|
||||
db_type = "--datastore-endpoint='mysql://root:e2e@tcp(#{NETWORK_PREFIX}.100:3306)/k3s'"
|
||||
elsif EXTERNAL_DB == "postgres"
|
||||
@ -70,7 +70,7 @@ def provision(vm, roles, role_num, node_num)
|
||||
k3s.config_mode = '0644' # side-step https://github.com/k3s-io/k3s/issues/4321
|
||||
end
|
||||
end
|
||||
if roles.include?("agent")
|
||||
if role.include?("agent")
|
||||
vm.provision 'k3s-install', type: 'k3s', run: 'once' do |k3s|
|
||||
k3s.args = %W[agent #{db_type} --server https://#{NETWORK_PREFIX}.100:6443 --flannel-iface=eth1]
|
||||
k3s.env = %W[K3S_KUBECONFIG_MODE=0644 K3S_TOKEN=vagrant #{install_type}]
|
||||
@ -128,10 +128,9 @@ Vagrant.configure("2") do |config|
|
||||
# over the node roles themselves
|
||||
NODE_ROLES.length.times do |i|
|
||||
name = NODE_ROLES[i]
|
||||
role_num = name.split("-", -1).pop.to_i
|
||||
config.vm.define name do |node|
|
||||
roles = name.split("-", -1)
|
||||
role_num = roles.pop.to_i
|
||||
provision(node.vm, roles, role_num, i)
|
||||
provision(node.vm, name, role_num, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -38,7 +38,7 @@ var _ = Describe("Verify Create", func() {
|
||||
It("Starts up with no issues", func() {
|
||||
var err error
|
||||
serverNodeNames, agentNodeNames, err = e2e.CreateCluster(*nodeOS, *serverCount, *agentCount)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(err).NotTo(HaveOccurred(), e2e.GetVagrantLog())
|
||||
fmt.Println("CLUSTER CONFIG")
|
||||
fmt.Println("OS:", *nodeOS)
|
||||
fmt.Println("Server Nodes:", serverNodeNames)
|
||||
|
Loading…
Reference in New Issue
Block a user