Skip to content

Commit

Permalink
Merge branch 'master' into fix-lastip
Browse files Browse the repository at this point in the history
  • Loading branch information
cnvergence authored Aug 23, 2024
2 parents 5af3899 + b197ad3 commit f3cb0d4
Show file tree
Hide file tree
Showing 14 changed files with 1,238 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ METALLB_CHART_REPO = https://metallb.github.io/metallb
METALLB_CONTROLLER_IMAGE = quay.io/metallb/controller:v$(METALLB_VERSION)
METALLB_SPEAKER_IMAGE = quay.io/metallb/speaker:v$(METALLB_VERSION)

KUBEVIRT_VERSION = v1.3.0
KUBEVIRT_VERSION = v1.3.1
KUBEVIRT_OPERATOR_IMAGE = quay.io/kubevirt/virt-operator:$(KUBEVIRT_VERSION)
KUBEVIRT_API_IMAGE = quay.io/kubevirt/virt-api:$(KUBEVIRT_VERSION)
KUBEVIRT_CONTROLLER_IMAGE = quay.io/kubevirt/virt-controller:$(KUBEVIRT_VERSION)
Expand Down
5 changes: 5 additions & 0 deletions charts/kube-ovn/templates/kube-ovn-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1603,12 +1603,17 @@ spec:
- jsonPath: .spec.namespaces
name: Namespaces
type: string
- jsonPath: .status.defaultLogicalSwitch
name: DefaultSubnet
type: string
name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
defaultSubnet:
type: string
enableExternal:
type: boolean
enableBfd:
Expand Down
19 changes: 12 additions & 7 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1846,12 +1846,17 @@ spec:
- jsonPath: .spec.namespaces
name: Namespaces
type: string
- jsonPath: .status.defaultLogicalSwitch
name: DefaultSubnet
type: string
name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
defaultSubnet:
type: string
enableExternal:
type: boolean
enableBfd:
Expand Down Expand Up @@ -3144,11 +3149,11 @@ rules:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- apiGroups:
- "certificates.k8s.io"
resources:
resources:
- "certificatesigningrequests"
verbs:
verbs:
- "get"
- "list"
- "watch"
Expand Down Expand Up @@ -3277,12 +3282,12 @@ rules:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- apiGroups:
- "certificates.k8s.io"
resources:
resources:
- "certificatesigningrequests"
verbs:
- "create"
verbs:
- "create"
- "get"
- "list"
- "watch"
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/kubeovn/ovsdb v0.0.0-20240410091831-5dd26006c475
github.com/mdlayher/arp v0.0.0-20220512170110-6706a2966875
github.com/moby/sys/mountinfo v0.7.2
github.com/onsi/ginkgo/v2 v2.20.0
github.com/onsi/ginkgo/v2 v2.20.1
github.com/onsi/gomega v1.34.1
github.com/osrg/gobgp/v3 v3.29.0
github.com/ovn-org/libovsdb v0.7.0
Expand All @@ -36,7 +36,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
github.com/vishvananda/netlink v1.2.1-beta.2.0.20240713210050-d13535d71ed3
github.com/vishvananda/netlink v1.2.1
go.uber.org/mock v0.4.0
golang.org/x/mod v0.20.0
golang.org/x/sys v0.24.0
Expand All @@ -53,8 +53,8 @@ require (
k8s.io/pod-security-admission v0.31.0
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
kernel.org/pub/linux/libs/security/libcap/cap v1.2.70
kubevirt.io/api v1.3.0
kubevirt.io/client-go v1.3.0
kubevirt.io/api v1.3.1
kubevirt.io/client-go v1.3.1
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/network-policy-api v0.1.5
)
Expand Down Expand Up @@ -222,7 +222,7 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa // indirect
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sync v0.8.0 // indirect
Expand Down Expand Up @@ -300,5 +300,5 @@ replace (
k8s.io/mount-utils => k8s.io/mount-utils v0.31.0
k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.31.0
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.31.0
kubevirt.io/client-go => github.com/kubeovn/kubevirt-client-go v0.0.0-20240814055642-5a8ca1345f4a
kubevirt.io/client-go => github.com/kubeovn/kubevirt-client-go v0.0.0-20240823060554-65405ba5499d
)
19 changes: 10 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ github.com/kubeovn/go-iptables v0.0.0-20230322103850-8619a8ab3dca h1:fTMjoho2et9
github.com/kubeovn/go-iptables v0.0.0-20230322103850-8619a8ab3dca/go.mod h1:jY1XeGzkx8ASNJ+SqQSxTESNXARkjvt+I6IJOTnzIjw=
github.com/kubeovn/gonetworkmanager/v2 v2.0.0-20230905082151-e28c4d73a589 h1:y9exo1hjCsq7jsGUzt11kxhTiEGrGSQ0ZqibAiZk2PQ=
github.com/kubeovn/gonetworkmanager/v2 v2.0.0-20230905082151-e28c4d73a589/go.mod h1:49upX+/hUyppWIqu58cumojyIwXdkA8k6reA/mQlKuI=
github.com/kubeovn/kubevirt-client-go v0.0.0-20240814055642-5a8ca1345f4a h1:KHAk2PZ53dR1FX7435wlIks9NIc5GrpsTSlXZSaFL38=
github.com/kubeovn/kubevirt-client-go v0.0.0-20240814055642-5a8ca1345f4a/go.mod h1:Rfh1OHje8XZhjGGzzRys7dSopk4uYduT/ZWZe0ailto=
github.com/kubeovn/kubevirt-client-go v0.0.0-20240823060554-65405ba5499d h1:xytZ7pwEajOoKnu+7P4f/ljD+XsNeVjyG8e839ht1o8=
github.com/kubeovn/kubevirt-client-go v0.0.0-20240823060554-65405ba5499d/go.mod h1:KLjiIn15GHVtlp8DZTngKY5APnPGfvQS7V7kgOTrB5o=
github.com/kubeovn/libovsdb v0.0.0-20240814054845-978196448fb2 h1:jH4yKIJLu2ZBy6fLMrlVa27ccgjzc53rsGDzNvddh0E=
github.com/kubeovn/libovsdb v0.0.0-20240814054845-978196448fb2/go.mod h1:od3agzU0e50RPBxap7mMvBWZ+u37kqX0W849BYufdHI=
github.com/kubeovn/ovsdb v0.0.0-20240410091831-5dd26006c475 h1:KZba2Kj9TXCUdUSqOR3eiy4VvkkIyhDVImYmYs6GQWU=
Expand Down Expand Up @@ -437,8 +437,9 @@ github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xl
github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
github.com/onsi/ginkgo/v2 v2.17.2/go.mod h1:nP2DPOQoNsQmsVyv5rDA8JkXQoCs6goXIvr/PRJ1eCc=
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
github.com/onsi/ginkgo/v2 v2.20.0 h1:PE84V2mHqoT1sglvHc8ZdQtPcwmvvt29WLEEO3xmdZw=
github.com/onsi/ginkgo/v2 v2.20.0/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI=
github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo=
github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
Expand Down Expand Up @@ -580,8 +581,8 @@ github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtse
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE=
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75/go.mod h1:KO6IkyS8Y3j8OdNO85qEYBsRPuteD+YciPomcXdrMnk=
github.com/vishvananda/netlink v1.2.1-beta.2.0.20240713210050-d13535d71ed3 h1:z77sOcayXxSukV2QIDn5pg7kYx9V5rGoYZLr4syF5kk=
github.com/vishvananda/netlink v1.2.1-beta.2.0.20240713210050-d13535d71ed3/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs=
github.com/vishvananda/netlink v1.2.1 h1:pfLv/qlJUwOTPvtWREA7c3PI4u81YkqZw1DYhI2HmLA=
github.com/vishvananda/netlink v1.2.1/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs=
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
Expand Down Expand Up @@ -672,8 +673,8 @@ golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI=
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 h1:kx6Ds3MlpiUHKj7syVnbp57++8WpuKPcR5yjLBjvLEA=
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand Down Expand Up @@ -1038,8 +1039,8 @@ kernel.org/pub/linux/libs/security/libcap/cap v1.2.70 h1:QnLPkuDWWbD5C+3DUA2IUXa
kernel.org/pub/linux/libs/security/libcap/cap v1.2.70/go.mod h1:/iBwcj9nbLejQitYvUm9caurITQ6WyNHibJk6Q9fiS4=
kernel.org/pub/linux/libs/security/libcap/psx v1.2.70 h1:HsB2G/rEQiYyo1bGoQqHZ/Bvd6x1rERQTNdPr1FyWjI=
kernel.org/pub/linux/libs/security/libcap/psx v1.2.70/go.mod h1:+l6Ee2F59XiJ2I6WR5ObpC1utCQJZ/VLsEbQCD8RG24=
kubevirt.io/api v1.3.0 h1:9sGElMmnRU50pGED+MPPD2OwQl4S5lvjCUjm+t0mI90=
kubevirt.io/api v1.3.0/go.mod h1:e6LkElYZZm8NcP2gKlFVHZS9pgNhIARHIjSBSfeiP1s=
kubevirt.io/api v1.3.1 h1:MoTNo/zvDlZ44c2ocXLPln8XTaQOeUodiYbEKrTCqv4=
kubevirt.io/api v1.3.1/go.mod h1:tCn7VAZktEvymk490iPSMPCmKM9UjbbfH2OsFR/IOLU=
kubevirt.io/containerized-data-importer-api v1.58.1 h1:Zbf0pCvxb4fBvtMR6uI2OIJZ4UfwFxripzOLMO4HPbI=
kubevirt.io/containerized-data-importer-api v1.58.1/go.mod h1:Y/8ETgHS1GjO89bl682DPtQOYEU/1ctPFBz6Sjxm4DM=
kubevirt.io/controller-lifecycle-operator-sdk/api v0.0.0-20220329064328-f3cc58c6ed90 h1:QMrd0nKP0BGbnxTqakhDZAUhGKxPiPiN5gSDqKUmGGc=
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/kubeovn/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ type Vpc struct {
}

type VpcSpec struct {
DefaultSubnet string `json:"defaultSubnet,omitempty"`
Namespaces []string `json:"namespaces,omitempty"`
StaticRoutes []*StaticRoute `json:"staticRoutes,omitempty"`
PolicyRoutes []*PolicyRoute `json:"policyRoutes,omitempty"`
Expand Down
11 changes: 11 additions & 0 deletions pkg/controller/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ func (c *Controller) handleAddNamespace(key string) error {
break
}
}
// check if subnet is in custom vpc with configured defaultSubnet, then annotate the namespace with this subnet
if s.Spec.Vpc != "" && s.Spec.Vpc != c.config.ClusterRouter {
vpc, err := c.vpcsLister.Get(s.Spec.Vpc)
if err != nil {
klog.Errorf("failed to get custom vpc %v", err)
return err
}
if s.Name == vpc.Spec.DefaultSubnet {
lss = []string{s.Name}
}
}
}

for _, p := range ippools {
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,10 @@ func (c *Controller) getVpcSubnets(vpc *kubeovnv1.Vpc) (subnets []string, defaul
if subnet.Spec.Default {
defaultSubnet = subnet.Name
}

if vpc.Name != util.DefaultVpc && vpc.Spec.DefaultSubnet != "" && vpc.Spec.DefaultSubnet == subnet.Name {
defaultSubnet = vpc.Spec.DefaultSubnet
}
}
return
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/daemon/tproxy_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/vishvananda/netlink"
"golang.org/x/sys/unix"
"k8s.io/klog/v2"
"k8s.io/utils/ptr"

kubeovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1"
"github.com/kubeovn/kube-ovn/pkg/ovs"
Expand Down Expand Up @@ -159,7 +160,7 @@ func (c *Controller) cleanTProxyRoutes(protocol string) {
}
}

func addRuleIfNotExist(family, mark, mask, table int) error {
func addRuleIfNotExist(family int, mark, mask uint32, table int) error {
curRules, err := netlink.RuleListFiltered(family, &netlink.Rule{Mark: mark}, netlink.RT_FILTER_MARK)
if err != nil {
return fmt.Errorf("list rules with mark %x failed err: %w", mark, err)
Expand All @@ -171,7 +172,7 @@ func addRuleIfNotExist(family, mark, mask, table int) error {

rule := netlink.NewRule()
rule.Mark = mark
rule.Mask = mask
rule.Mask = ptr.To(mask)
rule.Table = table
rule.Family = family

Expand All @@ -183,7 +184,7 @@ func addRuleIfNotExist(family, mark, mask, table int) error {
return nil
}

func deleteRuleIfExists(family, mark int) error {
func deleteRuleIfExists(family int, mark uint32) error {
curRules, err := netlink.RuleListFiltered(family, &netlink.Rule{Mark: mark}, netlink.RT_FILTER_MARK)
if err != nil {
return fmt.Errorf("list rules with mark %x failed err: %w", mark, err)
Expand Down
Loading

0 comments on commit f3cb0d4

Please sign in to comment.