Skip to content

Commit

Permalink
refactor lb svc e2e (#4236)
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <[email protected]>
  • Loading branch information
zhangzujian committed Jul 6, 2024
1 parent 7de95ba commit 929e336
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 137 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,6 @@ kind-install-lb-svc:
$(call kind_load_image,kube-ovn,$(VPC_NAT_GW_IMG))
@$(MAKE) ENABLE_LB_SVC=true CNI_CONFIG_PRIORITY=10 kind-install
@$(MAKE) kind-install-multus
kubectl apply -f yamls/lb-svc-attachment.yaml

.PHONY: kind-install-webhook
kind-install-webhook: kind-install
Expand Down
75 changes: 75 additions & 0 deletions test/e2e/framework/cni.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package framework

import (
"encoding/json"

"github.com/containernetworking/cni/pkg/types"
nadv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
"k8s.io/kubernetes/test/e2e/framework"

"github.com/onsi/ginkgo/v2"

"github.com/kubeovn/kube-ovn/pkg/netconf"
"github.com/kubeovn/kube-ovn/pkg/request"
"github.com/kubeovn/kube-ovn/pkg/util"
)

const CNIVersion = "0.3.1"

// https://github.com/containernetworking/plugins/blob/main/plugins/main/macvlan/macvlan.go#L37
type MacvlanNetConf struct {
netconf.NetConf
Master string `json:"master"`
Mode string `json:"mode"`
MTU int `json:"mtu"`
Mac string `json:"mac,omitempty"`
LinkContNs bool `json:"linkInContainer,omitempty"`

RuntimeConfig struct {
Mac string `json:"mac,omitempty"`
} `json:"runtimeConfig,omitempty"`
}

func MakeMacvlanNetworkAttachmentDefinition(name, namespace, master, mode, provider string, routes []request.Route) *nadv1.NetworkAttachmentDefinition {
ginkgo.GinkgoHelper()

config := &MacvlanNetConf{
NetConf: netconf.NetConf{
NetConf: types.NetConf{
CNIVersion: CNIVersion,
Type: "macvlan",
},
IPAM: &netconf.IPAMConf{
Type: util.CniTypeName,
ServerSocket: "/run/openvswitch/kube-ovn-daemon.sock",
Provider: provider,
Routes: routes,
},
},
Master: master,
Mode: mode,
LinkContNs: true,
}
buf, err := json.MarshalIndent(config, "", " ")
framework.ExpectNoError(err)

return MakeNetworkAttachmentDefinition(name, namespace, string(buf))
}

func MakeOVNNetworkAttachmentDefinition(name, namespace, provider string, routes []request.Route) *nadv1.NetworkAttachmentDefinition {
ginkgo.GinkgoHelper()

config := &netconf.NetConf{
NetConf: types.NetConf{
CNIVersion: CNIVersion,
Type: util.CniTypeName,
},
ServerSocket: "/run/openvswitch/kube-ovn-daemon.sock",
Provider: provider,
Routes: routes,
}
buf, err := json.MarshalIndent(config, "", " ")
framework.ExpectNoError(err)

return MakeNetworkAttachmentDefinition(name, namespace, string(buf))
}
Loading

0 comments on commit 929e336

Please sign in to comment.