diff --git a/kola/tests/kubeadm/kubeadm.go b/kola/tests/kubeadm/kubeadm.go index 31e709141..44b473873 100644 --- a/kola/tests/kubeadm/kubeadm.go +++ b/kola/tests/kubeadm/kubeadm.go @@ -33,12 +33,23 @@ import ( ) var ( + // CNIs is the list of CNIs to deploy + // in the cluster setup + CNIs = []string{ + "calico", + "flannel", + "cilium", + } // params are used to render script templates // Release is the kubernetes release version we want to use // ReleaseVersion is the version of the kubelet service and kubeadm dropin // TODO: when a new version of kubernetes will be tested, it would be nice // to have a map[string]Release with Release struct holding the parameter below params = map[string]interface{}{ + // TODO: it's actually the CLI version + // we should pass the CLI and cilium version + // https://github.com/cilium/cilium-cli/issues/118 + "CiliumVersion": "v0.8.3", "CNIVersion": "v0.8.7", "CRIctlVersion": "v1.17.0", "ReleaseVersion": "v0.4.0", @@ -64,18 +75,23 @@ systemd: ) func init() { - register.Register(®ister.Test{ - Name: "kubeadm.base", - Distros: []string{"cl"}, - ExcludePlatforms: []string{"esx"}, - Run: kubeadmBaseTest, - }) + for _, CNI := range CNIs { + register.Register(®ister.Test{ + Name: fmt.Sprintf("kubeadm.%s.base", CNI), + Distros: []string{"cl"}, + ExcludePlatforms: []string{"esx"}, + Run: func(c cluster.TestCluster) { + kubeadmBaseTest(c, CNI) + }, + }) + } } // kubeadmBaseTest asserts that the cluster is up and running -func kubeadmBaseTest(c cluster.TestCluster) { +func kubeadmBaseTest(c cluster.TestCluster, CNI string) { board := kola.QEMUOptions.Board params["Arch"] = strings.SplitN(board, "-", 2)[0] + params["CNI"] = CNI kubectl, err := setup(c) if err != nil { c.Fatalf("unable to setup cluster: %v", err) diff --git a/kola/tests/kubeadm/templates.go b/kola/tests/kubeadm/templates.go index fa9e548ca..6943a6f07 100644 --- a/kola/tests/kubeadm/templates.go +++ b/kola/tests/kubeadm/templates.go @@ -185,6 +185,14 @@ storage: hash: function: sha512 sum: {{ .KubectlSum }} +{{ if eq .CNI "cilium" }} + - path: {{ .DownloadDir }}/cilium.tar.gz + filesystem: root + mode: 0755 + contents: + remote: + url: https://github.com/cilium/cilium-cli/releases/download/{{ .CiliumVersion }}/cilium-linux-amd64.tar.gz +{{ end }} - path: /home/core/install.sh filesystem: root mode: 0755 @@ -280,6 +288,7 @@ etcd: {{ end }} EOF +{{ if eq .CNI "calico" }} cat << EOF > calico.yaml # Source: https://docs.projectcalico.org/manifests/custom-resources.yaml apiVersion: operator.tigera.io/v1 @@ -298,6 +307,7 @@ spec: nodeSelector: all() flexVolumePath: /opt/libexec/kubernetes/kubelet-plugins/volume/exec/ EOF +{{ end }} { systemctl enable --quiet --now kubelet @@ -307,8 +317,23 @@ EOF cp /etc/kubernetes/admin.conf /home/core/.kube/config chown -R core:core /home/core/.kube; chmod a+r /home/core/.kube/config; +{{ if eq .CNI "calico" }} kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml kubectl apply -f calico.yaml +{{ end }} +{{ if eq .CNI "flannel" }} + curl -sSfL https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml > kube-flannel.yml + sed -i "s#10.244.0.0/16#{{ .PodSubnet }}#" kube-flannel.yml + kubectl apply -f kube-flannel.yml +{{ end }} +{{ if eq .CNI "cilium" }} + sudo tar -xf {{ .DownloadDir }}/cilium.tar.gz -C {{ .DownloadDir }} + /opt/bin/cilium install \ + --config enable-endpoint-routes=true \ + --config cluster-pool-ipv4-cidr={{ .PodSubnet }} + # --wait will wait for status to report success + /opt/bin/cilium status --wait +{{ end }} } 1>&2