diff --git a/test/e2e/common.go b/test/e2e/common.go index 896a1d9f6d92..b82111cd3288 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -36,6 +36,8 @@ const ( KubernetesVersion = "KUBERNETES_VERSION" CNIPath = "CNI" CNIResources = "CNI_RESOURCES" + CNIPath2 = "CNI2" + CNIResources2 = "CNI_RESOURCES2" KubernetesVersionUpgradeFrom = "KUBERNETES_VERSION_UPGRADE_FROM" KubernetesVersionUpgradeTo = "KUBERNETES_VERSION_UPGRADE_TO" EtcdVersionUpgradeTo = "ETCD_VERSION_UPGRADE_TO" diff --git a/test/e2e/config/docker-dev.yaml b/test/e2e/config/docker-dev.yaml index bd9775a2c9d7..a3c0e925ef57 100644 --- a/test/e2e/config/docker-dev.yaml +++ b/test/e2e/config/docker-dev.yaml @@ -111,6 +111,7 @@ variables: DOCKER_POD_CIDRS: "192.168.0.0/16" #CNI: "./data/cni/calico/calico.yaml" CNI: "./data/cni/kindnet/kindnet.yaml" + CNI2: "./data/cni/kindnet/kindnet2.yaml" EXP_CLUSTER_RESOURCE_SET: "true" intervals: diff --git a/test/e2e/data/cni/kindnet/kindnet2.yaml b/test/e2e/data/cni/kindnet/kindnet2.yaml new file mode 100644 index 000000000000..8995ca640348 --- /dev/null +++ b/test/e2e/data/cni/kindnet/kindnet2.yaml @@ -0,0 +1,113 @@ +# kindnetd networking manifest +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: kindnet +rules: + - apiGroups: + - policy + resources: + - podsecuritypolicies + verbs: + - use + resourceNames: + - kindnet + - apiGroups: + - "" + resources: + - nodes + verbs: + - list + - watch +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: kindnet +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: kindnet +subjects: + - kind: ServiceAccount + name: kindnet + namespace: kube-system +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: kindnet + namespace: kube-system +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: kindnet + namespace: kube-system + labels: + tier: node + app: kindnet + k8s-app: kindnet +spec: + selector: + matchLabels: + app: kindnet + template: + metadata: + labels: + tier: node + app: kindnet + k8s-app: kindnet + spec: + hostNetwork: true + tolerations: + - operator: Exists + effect: NoSchedule + serviceAccountName: kindnet + containers: + - name: kindnet-cni + image: kindest/kindnetd:0.5.4 + env: + - name: HOST_IP + valueFrom: + fieldRef: + fieldPath: status.hostIP + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: POD_SUBNET + value: "192.168.0.0/16" + volumeMounts: + - name: cni-cfg + mountPath: /etc/cni/net.d + - name: xtables-lock + mountPath: /run/xtables.lock + readOnly: false + - name: lib-modules + mountPath: /lib/modules + readOnly: true + resources: + requests: + cpu: "100m" + memory: "50Mi" + limits: + cpu: "100m" + memory: "50Mi" + securityContext: + privileged: false + capabilities: + add: ["NET_RAW", "NET_ADMIN"] + volumes: + - name: cni-cfg + hostPath: + path: /etc/cni/net.d + - name: xtables-lock + hostPath: + path: /run/xtables.lock + type: FileOrCreate + - name: lib-modules + hostPath: + path: /lib/modules +--- \ No newline at end of file diff --git a/test/e2e/data/infrastructure-docker/cluster-template.yaml b/test/e2e/data/infrastructure-docker/cluster-template.yaml index ce66062a76e1..8d998d9be6ea 100644 --- a/test/e2e/data/infrastructure-docker/cluster-template.yaml +++ b/test/e2e/data/infrastructure-docker/cluster-template.yaml @@ -130,7 +130,7 @@ apiVersion: v1 kind: ConfigMap metadata: name: "cni-${CLUSTER_NAME}-crs-0" -data: ${CNI_RESOURCES} +data: ${CNI_RESOURCES2} --- apiVersion: addons.cluster.x-k8s.io/v1alpha3 kind: ClusterResourceSet diff --git a/test/e2e/quick_start.go b/test/e2e/quick_start.go index 5faea5972c6c..65d8f5c261ea 100644 --- a/test/e2e/quick_start.go +++ b/test/e2e/quick_start.go @@ -19,11 +19,10 @@ package e2e import ( "context" "fmt" - "os" - "path/filepath" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "os" + "path/filepath" corev1 "k8s.io/api/core/v1" "k8s.io/utils/pointer" @@ -72,6 +71,10 @@ func QuickStartSpec(ctx context.Context, inputGetter func() QuickStartSpecInput) By("Creating a workload cluster") + // Read CNI file and set CNI_RESOURCES environmental variable + Expect(input.E2EConfig.Variables).To(HaveKey(CNIPath2), "Missing %s variable in the config", CNIPath2) + clusterctl.SetCNIEnvVar(input.E2EConfig.GetVariable(CNIPath2), CNIResources2) + cluster, _, _ = clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{ ClusterProxy: input.BootstrapClusterProxy, ConfigCluster: clusterctl.ConfigClusterInput{