Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ovn lb select the local chassis's backend prefer #4894

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions .github/workflows/build-x86-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3144,6 +3144,151 @@ jobs:
name: kube-ovn-connectivity-e2e-${{ matrix.mode }}-ko-log
path: kube-ovn-connectivity-e2e-${{ matrix.mode }}-ko-log.tar.gz


kube-ovn-underlay-metallb-e2e:
name: OVN METALLB E2E
needs:
- build-kube-ovn
- build-e2e-binaries
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: jlumbroso/free-disk-space@v1.3.1
with:
android: true
dotnet: true
haskell: true
docker-images: false
large-packages: false
tool-cache: false
swap-storage: false

- uses: actions/checkout@v4

- name: Create the default branch directory
if: (github.base_ref || github.ref_name) != github.event.repository.default_branch
run: mkdir -p test/e2e/source

- name: Check out the default branch
if: (github.base_ref || github.ref_name) != github.event.repository.default_branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
fetch-depth: 1
path: test/e2e/source

- name: Export E2E directory
run: |
if [ '${{ github.base_ref || github.ref_name }}' = '${{ github.event.repository.default_branch }}' ]; then
echo "E2E_DIR=." >> "$GITHUB_ENV"
else
echo "E2E_DIR=test/e2e/source" >> "$GITHUB_ENV"
fi

- uses: actions/setup-go@v5
id: setup-go
with:
go-version-file: ${{ env.E2E_DIR }}/go.mod
check-latest: true
cache: false

- name: Export Go full version
run: echo "GO_VERSION=${{ steps.setup-go.outputs.go-version }}" >> "$GITHUB_ENV"

- name: Go cache
uses: actions/cache/restore@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-e2e-go-${{ env.GO_VERSION }}-x86-${{ hashFiles(format('{0}/**/go.sum', env.E2E_DIR)) }}
restore-keys: ${{ runner.os }}-e2e-go-${{ env.GO_VERSION }}-x86-

- name: Install kind
uses: helm/kind-action@v1.12.0
with:
version: ${{ env.KIND_VERSION }}
install_only: true

- name: Install ginkgo
working-directory: ${{ env.E2E_DIR }}
run: go install -v -mod=mod github.com/onsi/ginkgo/v2/ginkgo

- name: Download kube-ovn image
uses: actions/download-artifact@v4
with:
name: kube-ovn

- name: Load images
run: docker load -i kube-ovn.tar

- name: Set environment variables
run: |
if [ $(($RANDOM%2)) -ne 0 ]; then
# run as root and use valgrind to debug memory leak
echo "VERSION=$(cat VERSION)-debug" >> "$GITHUB_ENV"
echo "DEBUG_WRAPPER=valgrind" >> "$GITHUB_ENV"
fi

- name: Create kind cluster
run: |
pipx install jinjanator
make kind-init

- name: Install Kube-OVN
id: install
run: make kind-install-metallb-pool-from-underlay
zhangzujian marked this conversation as resolved.
Show resolved Hide resolved

- name: Run Ovn Metallb and Kube-OVN Combine E2E
id: kube-ovn-underlay-metallb-e2e
working-directory: ${{ env.E2E_DIR }}
env:
E2E_BRANCH: ${{ github.base_ref || github.ref_name }}
run: make kube-ovn-underlay-metallb-e2e

- name: Collect k8s events
if: failure() && ( steps.ovn-metallb-e2e.conclusion == 'failure')
run: |
kubectl get events -A -o yaml > kube-ovn-underlay-metallb-e2e-events.yaml
tar zcf kube-ovn-underlay-metallb-e2e-events.tar.gz kube-ovn-underlay-metallb-e2e-events.yaml

- name: Upload k8s events
uses: actions/upload-artifact@v4
if: failure() && (steps.kube-ovn-underlay-metallb-e2e.conclusion == 'failure')
with:
name: kube-ovn-underlay-metallb-e2e-events
path: kube-ovn-underlay-metallb-e2e-events.tar.gz

- name: Collect apiserver audit logs
if: failure() && (steps.kube-ovn-underlay-metallb-e2e.conclusion == 'failure')
run: |
docker cp kube-ovn-control-plane:/var/log/kubernetes/kube-apiserver-audit.log .
tar zcf kube-ovn-underlay-metallb-e2e-audit-log.tar.gz kube-apiserver-audit.log

- name: Upload apiserver audit logs
uses: actions/upload-artifact@v4
if: failure() && (steps.kube-ovn-underlay-metallb-e2e.conclusion == 'failure')
with:
name: kube-ovn-underlay-metallb-e2e-audit-log
path: kube-ovn-underlay-metallb-e2e-audit-log.tar.gz

- name: kubectl ko log
if: failure() && (steps.kube-ovn-underlay-metallb-e2e.conclusion == 'failure')
run: |
make kubectl-ko-log
mv kubectl-ko-log.tar.gz kube-ovn-underlay-metallb-e2e-ko-log.tar.gz

- name: upload kubectl ko log
uses: actions/upload-artifact@v4
if: failure() && (steps.kube-ovn-underlay-metallb-e2e.conclusion == 'failure')
with:
name: kube-ovn-underlay-metallb-e2e-ko-log
path: kube-ovn-underlay-metallb-e2e-ko-log.tar.gz

- name: Check kube ovn pod restarts
if: ${{ success() || (failure() && (steps.install.conclusion == 'failure' || steps.kube-ovn-underlay-metallb-e2e.conclusion == 'failure')) }}
run: make check-kube-ovn-pod-restarts

push:
name: Push Images
needs:
Expand All @@ -3153,6 +3298,7 @@ jobs:
- kube-ovn-conformance-e2e
- kube-ovn-ic-conformance-e2e
- kube-ovn-ipsec-e2e
- kube-ovn-underlay-metallb-e2e
- multus-conformance-e2e
- vpc-egress-gateway-e2e
- ovn-vpc-nat-gw-conformance-e2e
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,9 @@ kind-install-metallb:
--set speaker.frr.image.tag=$(FRR_VERSION)
$(call kubectl_wait_exist_and_ready,metallb-system,deployment,metallb-controller)
$(call kubectl_wait_exist_and_ready,metallb-system,daemonset,metallb-speaker)

.PHONY: kind-configure-metallb
kind-configure-metallb:
@metallb_pool=$(shell echo $(KIND_IPV4_SUBNET) | sed 's/.[^.]\+$$/.201/')-$(shell echo $(KIND_IPV4_SUBNET) | sed 's/.[^.]\+$$/.250/') \
jinjanate yamls/metallb-cr.yaml.j2 -o metallb-cr.yaml
kubectl apply -f metallb-cr.yaml
Expand Down Expand Up @@ -977,6 +980,11 @@ kind-install-anp: kind-load-image
kubectl apply -f "$(BANP_CR_YAML)"
@$(MAKE) ENABLE_ANP=true kind-install

.PHONY: kind-install-metallb-pool-from-underlay
kind-install-metallb-pool-from-underlay: kind-load-image
@$(MAKE) ENABLE_OVN_LB_PREFER_LOCAL=true LS_CT_SKIP_DST_LPORT_IPS=false kind-install
@$(MAKE) kind-install-metallb

.PHONY: kind-reload
kind-reload: kind-reload-ovs
kubectl delete pod -n kube-system -l app=kube-ovn-controller
Expand Down
1 change: 1 addition & 0 deletions charts/kube-ovn/templates/controller-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ spec:
- --ovsdb-con-timeout={{- .Values.func.OVSDB_CON_TIMEOUT }}
- --ovsdb-inactivity-timeout={{- .Values.func.OVSDB_INACTIVITY_TIMEOUT }}
- --enable-live-migration-optimize={{- .Values.func.ENABLE_LIVE_MIGRATION_OPTIMIZE }}
- --enable-ovn-lb-prefer-local={{- .Values.func.ENABLE_OVN_LB_PREFER_LOCAL }}
- --image={{ .Values.global.registry.address }}/{{ .Values.global.images.kubeovn.repository }}:{{ .Values.global.images.kubeovn.tag }}
securityContext:
runAsUser: {{ include "kubeovn.runAsUser" . }}
Expand Down
2 changes: 2 additions & 0 deletions charts/kube-ovn/templates/kube-ovn-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2564,6 +2564,8 @@ spec:
type: boolean
enableMulticastSnoop:
type: boolean
enableExternalLBAddress:
type: boolean
routeTable:
type: string
namespaceSelectors:
Expand Down
1 change: 1 addition & 0 deletions charts/kube-ovn/templates/ovn-CR.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ rules:
- nodes
- nodes/status
- pods
- services
verbs:
- get
- list
Expand Down
1 change: 1 addition & 0 deletions charts/kube-ovn/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func:
OVSDB_CON_TIMEOUT: 3
OVSDB_INACTIVITY_TIMEOUT: 10
ENABLE_LIVE_MIGRATION_OPTIMIZE: true
ENABLE_OVN_LB_PREFER_LOCAL: false

ipv4:
POD_CIDR: "10.16.0.0/16"
Expand Down
4 changes: 3 additions & 1 deletion dist/images/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ RUN cd /usr/src/ && git clone -b branch-24.03 --depth=1 https://github.com/ovn-o
# support dedicated BFD LRP
curl -s https://github.com/kubeovn/ovn/commit/40345aa35d03c93cde877ccfa8111346291ebc7c.patch | git apply && \
# skip node local dns ip conntrack when set acl
curl -s https://github.com/kubeovn/ovn/commit/e7d3ba53cdcbc524bb29c54ddb07b83cc4258ed7.patch | git apply
curl -s https://github.com/kubeovn/ovn/commit/e7d3ba53cdcbc524bb29c54ddb07b83cc4258ed7.patch | git apply && \
# select local backend first
curl -s https://github.com/kubeovn/ovn/commit/1fed88af496939d6e526b38897bc10d56557c5c4.patch | git apply

RUN apt install -y build-essential fakeroot \
autoconf automake bzip2 debhelper-compat dh-exec dh-python dh-sequence-python3 dh-sequence-sphinxdoc \
Expand Down
5 changes: 5 additions & 0 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ SET_VXLAN_TX_OFF=${SET_VXLAN_TX_OFF:-false}
OVSDB_CON_TIMEOUT=${OVSDB_CON_TIMEOUT:-3}
OVSDB_INACTIVITY_TIMEOUT=${OVSDB_INACTIVITY_TIMEOUT:-10}
ENABLE_LIVE_MIGRATION_OPTIMIZE=${ENABLE_LIVE_MIGRATION_OPTIMIZE:-true}
ENABLE_OVN_LB_PREFER_LOCAL=${ENABLE_OVN_LB_PREFER_LOCAL:-false}

# debug
DEBUG_WRAPPER=${DEBUG_WRAPPER:-}
Expand Down Expand Up @@ -2810,6 +2811,8 @@ spec:
type: boolean
enableMulticastSnoop:
type: boolean
enableExternalLBAddress:
type: boolean
routeTable:
type: string
namespaceSelectors:
Expand Down Expand Up @@ -3667,6 +3670,7 @@ rules:
- nodes
- nodes/status
- pods
- services
verbs:
- get
- list
Expand Down Expand Up @@ -4729,6 +4733,7 @@ spec:
- --ovsdb-con-timeout=$OVSDB_CON_TIMEOUT
- --ovsdb-inactivity-timeout=$OVSDB_INACTIVITY_TIMEOUT
- --enable-live-migration-optimize=$ENABLE_LIVE_MIGRATION_OPTIMIZE
- --enable-ovn-lb-prefer-local=$ENABLE_OVN_LB_PREFER_LOCAL
- --image=$REGISTRY/kube-ovn:$VERSION
securityContext:
runAsUser: ${RUN_AS_USER}
Expand Down
10 changes: 10 additions & 0 deletions e2e.mk
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ e2e-build:
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/kubevirt
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/webhook
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/connectivity
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/metallb

.PHONY: k8s-conformance-e2e
k8s-conformance-e2e:
Expand Down Expand Up @@ -251,3 +252,12 @@ kube-ovn-connectivity-e2e:
E2E_NETWORK_MODE=$(E2E_NETWORK_MODE) \
ginkgo $(GINKGO_OUTPUT_OPT) --procs 2 --randomize-all -v \
--focus=CNI:Kube-OVN ./test/e2e/connectivity -- $(TEST_BIN_ARGS)

.PHONY: kube-ovn-underlay-metallb-e2e
kube-ovn-underlay-metallb-e2e:
ginkgo build $(E2E_BUILD_FLAGS) ./test/e2e/metallb
E2E_BRANCH=$(E2E_BRANCH) \
E2E_IP_FAMILY=$(E2E_IP_FAMILY) \
E2E_NETWORK_MODE=$(E2E_NETWORK_MODE) \
ginkgo $(GINKGO_OUTPUT_OPT) $(GINKGO_PARALLEL_OPT) --randomize-all -v \
--focus=CNI:Kube-OVN ./test/e2e/metallb/metallb.test -- $(TEST_BIN_ARGS)
zhangzujian marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/containerd/containerd v1.7.22
github.com/containernetworking/cni v1.2.3
github.com/containernetworking/plugins v1.6.0
github.com/digitalocean/go-openvswitch v0.0.0-20240130171624-c0f7d42efe24
github.com/docker/docker v27.5.1+incompatible
github.com/emicklei/go-restful/v3 v3.12.1
github.com/evanphx/json-patch/v5 v5.9.11
Expand Down Expand Up @@ -41,6 +42,7 @@ require (
github.com/stretchr/testify v1.10.0
github.com/vishvananda/netlink v1.3.1-0.20240905180732-b1ce50cfa9be
go.uber.org/mock v0.5.0
go.universe.tf/metallb v0.14.9
golang.org/x/mod v0.23.0
golang.org/x/sys v0.30.0
golang.org/x/time v0.10.0
Expand Down
Loading
Loading