Skip to content

Commit

Permalink
support underlay mode with single nic
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed May 25, 2021
1 parent d6c96d0 commit 9e71562
Show file tree
Hide file tree
Showing 8 changed files with 384 additions and 8 deletions.
106 changes: 105 additions & 1 deletion .github/workflows/build-x86-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,53 @@ jobs:
sudo chmod 666 /home/runner/.kube/config
make e2e
single-vlan-e2e:
needs: build
name: 1-master-vlan-e2e
runs-on: ubuntu-18.04
timeout-minutes: 30
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Install Kind
env:
KIND_VERSION: v0.9.0
run: |
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
- name: Init Kind
run: |
pip install j2cli --user
pip install "j2cli[yaml]" --user
sudo PATH=~/.local/bin:$PATH make kind-init
- name: Download image
uses: actions/download-artifact@v2
with:
name: image

- name: Install Kube-OVN
run: |
docker load --input image.tar
sudo make kind-install-vlan
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go

- name: Run E2E
run: |
go get -u github.com/onsi/ginkgo/ginkgo
go get -u github.com/onsi/gomega/...
sudo kubectl cluster-info
sudo chmod 666 /home/runner/.kube/config
make e2e-vlan
single-node-e2e:
needs: build
name: 1-node-e2e
Expand Down Expand Up @@ -240,8 +287,65 @@ jobs:
docker load --input image.tar
sudo make kind-install-ipv6
ipv6-vlan-e2e:
needs: build
name: ipv6-vlan-e2e
runs-on: ubuntu-18.04
timeout-minutes: 30
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Install Kind
env:
KIND_VERSION: v0.9.0
run: |
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
- name: Init Kind
run: |
pip install j2cli --user
pip install "j2cli[yaml]" --user
sudo PATH=~/.local/bin:$PATH make kind-init-ipv6
- name: Download image
uses: actions/download-artifact@v2
with:
name: image

- name: Load Image
run: |
docker load --input image.tar
- name: Install Kube-OVN
run: |
docker load --input image.tar
sudo make kind-install-ipv6-vlan
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go

- name: Run E2E
run: |
go get -u github.com/onsi/ginkgo/ginkgo
go get -u github.com/onsi/gomega/...
sudo kubectl cluster-info
sudo chmod 666 /home/runner/.kube/config
make e2e-vlan
push:
needs: [single-e2e, single-node-e2e, ha-e2e, ipv6-e2e]
needs:
- single-e2e
- single-vlan-e2e
- single-node-e2e
- ha-e2e
- ipv6-e2e
- ipv6-vlan-e2e
name: push
runs-on: ubuntu-18.04
steps:
Expand Down
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,12 @@ kind-init:
kube_proxy_mode=ipvs ip_family=ipv4 ha=false single=false j2 yamls/kind.yaml.j2 -o yamls/kind.yaml
kind create cluster --config yamls/kind.yaml --name kube-ovn
kubectl describe no
docker exec kube-ovn-control-plane ip link add link eth0 mac1 type macvlan
docker exec kube-ovn-worker ip link add link eth0 mac1 type macvlan

kind-init-iptables:
kind delete cluster --name=kube-ovn
kube_proxy_mode=iptables ip_family=ipv4 ha=false single=false j2 yamls/kind.yaml.j2 -o yamls/kind.yaml
kind create cluster --config yamls/kind.yaml --name kube-ovn
kubectl describe no
docker exec kube-ovn-control-plane ip link add link eth0 mac1 type macvlan
docker exec kube-ovn-worker ip link add link eth0 mac1 type macvlan

kind-init-ha:
kind delete cluster --name=kube-ovn
Expand All @@ -101,8 +97,6 @@ kind-init-dual:
kube_proxy_mode=iptables ip_family=DualStack ha=false single=false j2 yamls/kind.yaml.j2 -o yamls/kind.yaml
kind create cluster --config yamls/kind.yaml --name kube-ovn
kubectl describe no
docker exec kube-ovn-control-plane ip link add link eth0 mac1 type macvlan
docker exec kube-ovn-worker ip link add link eth0 mac1 type macvlan
docker exec kube-ovn-worker sysctl -w net.ipv6.conf.all.disable_ipv6=0
docker exec kube-ovn-control-plane sysctl -w net.ipv6.conf.all.disable_ipv6=0

Expand All @@ -112,6 +106,12 @@ kind-install:
ENABLE_SSL=true dist/images/install.sh
kubectl describe no

kind-install-vlan:
kind load docker-image --name kube-ovn ${REGISTRY}/kube-ovn:${RELEASE_TAG}
kubectl taint node kube-ovn-control-plane node-role.kubernetes.io/master:NoSchedule-
ENABLE_SSL=true ENABLE_VLAN=true VLAN_NIC=eth0 dist/images/install.sh
kubectl describe no

kind-install-single:
kind load docker-image --name kube-ovn ${REGISTRY}/kube-ovn:${RELEASE_TAG}
ENABLE_SSL=true dist/images/install.sh
Expand All @@ -122,6 +122,11 @@ kind-install-ipv6:
kubectl taint node kube-ovn-control-plane node-role.kubernetes.io/master:NoSchedule-
ENABLE_SSL=true IPv6=true dist/images/install.sh

kind-install-ipv6-vlan:
kind load docker-image --name kube-ovn ${REGISTRY}/kube-ovn:${RELEASE_TAG}
kubectl taint node kube-ovn-control-plane node-role.kubernetes.io/master:NoSchedule-
ENABLE_SSL=true IPv6=true ENABLE_VLAN=true VLAN_NIC=eth0 dist/images/install.sh

kind-install-dual:
kind load docker-image --name kube-ovn ${REGISTRY}/kube-ovn:${RELEASE_TAG}
kubectl taint node kube-ovn-control-plane node-role.kubernetes.io/master:NoSchedule-
Expand All @@ -145,6 +150,12 @@ e2e:
kind load docker-image --name kube-ovn kubeovn/pause:3.2
ginkgo -mod=mod -progress -reportPassed --slowSpecThreshold=60 test/e2e

e2e-vlan:
echo "package node\n\nvar networkJSON = []byte(\`" > test/e2e-vlan/node/network.go
docker inspect -f '{{json .NetworkSettings.Networks.kind}}' kube-ovn-control-plane >> test/e2e-vlan/node/network.go
echo "\`)" >> test/e2e-vlan/node/network.go
ginkgo -mod=mod -progress -reportPassed --slowSpecThreshold=60 test/e2e-vlan

ut:
ginkgo -mod=mod -progress -reportPassed --slowSpecThreshold=60 test/unittest

Expand Down
8 changes: 8 additions & 0 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -euo pipefail
IPv6=${IPv6:-false}
DualStack=${DualStack:-false}
ENABLE_SSL=${ENABLE_SSL:-false}
ENABLE_VLAN=${ENABLE_VLAN:-false}
ENABLE_MIRROR=${ENABLE_MIRROR:-false}
HW_OFFLOAD=${HW_OFFLOAD:-false}
IFACE="" # The nic to support container network can be a nic name or a group of regex separated by comma, if empty will use the nic that the default route use
Expand Down Expand Up @@ -49,6 +50,13 @@ VLAN_NAME="ovn-vlan"
VLAN_ID="100"
VLAN_RANGE="1,4095"

if [ "$ENABLE_VLAN" = "true" ]; then
NETWORK_TYPE="vlan"
if [ "$VLAN_NIC" != "" ]; then
VLAN_INTERFACE_NAME="$VLAN_NIC"
fi
fi

# DPDK
DPDK="false"
DPDK_SUPPORTED_VERSIONS=("19.11")
Expand Down
11 changes: 10 additions & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,19 @@ go get -u github.com/onsi/gomega/...

make kind-init
make kind-install
# wait all pod ready
# wait all pods ready
make e2e
```

For Underlay/Vlan mode e2e tests, run following commands:

```sh
make kind-init
make kind-install-vlan
# wait all pods ready
make e2e-vlan
```

## ARM support

If you want to run Kube-OVN on arm64 platform, you need to build the arm64 images with docker multi-platform build.
Expand Down
42 changes: 42 additions & 0 deletions test/e2e-vlan/e2e_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package e2e_vlan_test

import (
"context"
"fmt"
"os"
"testing"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

_ "github.com/kubeovn/kube-ovn/test/e2e-vlan/node"
"github.com/kubeovn/kube-ovn/test/e2e/framework"
)

func TestE2e(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Kube-OVN Vlan E2E Suite")
}

var _ = SynchronizedAfterSuite(func() {}, func() {
f := framework.NewFramework("init", fmt.Sprintf("%s/.kube/config", os.Getenv("HOME")))
nss, err := f.KubeClientSet.CoreV1().Namespaces().List(context.Background(), metav1.ListOptions{LabelSelector: "e2e=true"})
if err != nil {
Fail(err.Error())
}
if nss != nil {
for _, ns := range nss.Items {
err := f.KubeClientSet.CoreV1().Namespaces().Delete(context.Background(), ns.Name, metav1.DeleteOptions{})
if err != nil {
Fail(err.Error())
}
}
}

err = f.OvnClientSet.KubeovnV1().Subnets().DeleteCollection(context.Background(), metav1.DeleteOptions{}, metav1.ListOptions{LabelSelector: "e2e=true"})
if err != nil {
Fail(err.Error())
}
})
1 change: 1 addition & 0 deletions test/e2e-vlan/node/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
network.go
4 changes: 4 additions & 0 deletions test/e2e-vlan/node/network.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package node

// use go:embed after upgrading Go to 1.16+
var networkJSON []byte

0 comments on commit 9e71562

Please sign in to comment.