Skip to content

Commit 4320301

Browse files
authored
u2o feature merge to 1.10 (#2227)
1 parent c92af9b commit 4320301

File tree

15 files changed

+465
-40
lines changed

15 files changed

+465
-40
lines changed

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,16 @@ kind-install-underlay-ipv4: kind-disable-hairpin kind-load-image kind-untaint-co
329329
ENABLE_VLAN=true VLAN_NIC=eth0 bash
330330
kubectl describe no
331331

332+
.PHONY: kind-install-underlay-u2o-interconnection-dual
333+
kind-install-underlay-u2o-interconnection-dual: kind-disable-hairpin kind-load-image kind-untaint-control-plane
334+
$(call docker_network_info,kind)
335+
@sed -e 's@^[[:space:]]*POD_CIDR=.*@POD_CIDR="$(KIND_IPV4_SUBNET),$(KIND_IPV6_SUBNET)"@' \
336+
-e 's@^[[:space:]]*POD_GATEWAY=.*@POD_GATEWAY="$(KIND_IPV4_GATEWAY),$(KIND_IPV6_GATEWAY)"@' \
337+
-e 's@^[[:space:]]*EXCLUDE_IPS=.*@EXCLUDE_IPS="$(KIND_IPV4_EXCLUDE_IPS),$(KIND_IPV6_EXCLUDE_IPS)"@' \
338+
-e 's@^VLAN_ID=.*@VLAN_ID="0"@' \
339+
dist/images/install.sh | \
340+
ENABLE_SSL=true DUAL_STACK=true ENABLE_VLAN=true VLAN_NIC=eth0 U2O_INTERCONNECTION=true bash
341+
332342
.PHONY: kind-install-underlay-hairpin-ipv4
333343
kind-install-underlay-hairpin-ipv4: kind-enable-hairpin kind-load-image kind-untaint-control-plane
334344
$(call docker_network_info,kind)

dist/images/install.sh

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ENABLE_SSL=${ENABLE_SSL:-false}
77
ENABLE_VLAN=${ENABLE_VLAN:-false}
88
CHECK_GATEWAY=${CHECK_GATEWAY:-true}
99
LOGICAL_GATEWAY=${LOGICAL_GATEWAY:-false}
10+
U2O_INTERCONNECTION=${U2O_INTERCONNECTION:-false}
1011
ENABLE_MIRROR=${ENABLE_MIRROR:-false}
1112
VLAN_NIC=${VLAN_NIC:-}
1213
HW_OFFLOAD=${HW_OFFLOAD:-false}
@@ -942,6 +943,9 @@ spec:
942943
- name: ExcludeIPs
943944
type: string
944945
jsonPath: .spec.excludeIps
946+
- name: U2OInterconnectionIP
947+
type: string
948+
jsonPath: .status.u2oInterconnectionIP
945949
schema:
946950
openAPIV3Schema:
947951
type: object
@@ -963,6 +967,8 @@ spec:
963967
type: string
964968
dhcpV6OptionsUUID:
965969
type: string
970+
u2oInterconnectionIP:
971+
type: string
966972
conditions:
967973
type: array
968974
items:
@@ -1083,6 +1089,8 @@ spec:
10831089
- allow
10841090
- drop
10851091
- reject
1092+
u2oInterconnection:
1093+
type: boolean
10861094
scope: Cluster
10871095
names:
10881096
plural: subnets
@@ -2585,6 +2593,7 @@ spec:
25852593
- --default-gateway=$POD_GATEWAY
25862594
- --default-gateway-check=$CHECK_GATEWAY
25872595
- --default-logical-gateway=$LOGICAL_GATEWAY
2596+
- --default-u2o-interconnection=$U2O_INTERCONNECTION
25882597
- --default-exclude-ips=$EXCLUDE_IPS
25892598
- --node-switch-cidr=$JOIN_CIDR
25902599
- --service-cluster-ip-range=$SVC_CIDR

pkg/apis/kubeovn/v1/types.go

+12-9
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ type SubnetSpec struct {
138138
IPv6RAConfigs string `json:"ipv6RAConfigs,omitempty"`
139139

140140
Acls []Acl `json:"acls,omitempty"`
141+
142+
U2OInterconnection bool `json:"u2oInterconnection,omitempty"`
141143
}
142144

143145
type Acl struct {
@@ -178,15 +180,16 @@ type SubnetStatus struct {
178180
// +patchStrategy=merge
179181
Conditions []SubnetCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
180182

181-
AvailableIPs float64 `json:"availableIPs"`
182-
UsingIPs float64 `json:"usingIPs"`
183-
V4AvailableIPs float64 `json:"v4availableIPs"`
184-
V4UsingIPs float64 `json:"v4usingIPs"`
185-
V6AvailableIPs float64 `json:"v6availableIPs"`
186-
V6UsingIPs float64 `json:"v6usingIPs"`
187-
ActivateGateway string `json:"activateGateway"`
188-
DHCPv4OptionsUUID string `json:"dhcpV4OptionsUUID"`
189-
DHCPv6OptionsUUID string `json:"dhcpV6OptionsUUID"`
183+
AvailableIPs float64 `json:"availableIPs"`
184+
UsingIPs float64 `json:"usingIPs"`
185+
V4AvailableIPs float64 `json:"v4availableIPs"`
186+
V4UsingIPs float64 `json:"v4usingIPs"`
187+
V6AvailableIPs float64 `json:"v6availableIPs"`
188+
V6UsingIPs float64 `json:"v6usingIPs"`
189+
ActivateGateway string `json:"activateGateway"`
190+
DHCPv4OptionsUUID string `json:"dhcpV4OptionsUUID"`
191+
DHCPv6OptionsUUID string `json:"dhcpV6OptionsUUID"`
192+
U2OInterconnectionIP string `json:"u2oInterconnectionIP"`
190193
}
191194

192195
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

pkg/controller/config.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ type Configuration struct {
3737
KubeFactoryClient kubernetes.Interface
3838
KubeOvnFactoryClient clientset.Interface
3939

40-
DefaultLogicalSwitch string
41-
DefaultCIDR string
42-
DefaultGateway string
43-
DefaultExcludeIps string
44-
DefaultGatewayCheck bool
45-
DefaultLogicalGateway bool
40+
DefaultLogicalSwitch string
41+
DefaultCIDR string
42+
DefaultGateway string
43+
DefaultExcludeIps string
44+
DefaultGatewayCheck bool
45+
DefaultLogicalGateway bool
46+
DefaultU2OInterconnection bool
4647

4748
ClusterRouter string
4849
NodeSwitch string
@@ -102,6 +103,8 @@ func ParseFlags() (*Configuration, error) {
102103
argDefaultLogicalGateway = pflag.Bool("default-logical-gateway", false, "Create a logical gateway for the default subnet instead of using underlay gateway. Take effect only when the default subnet is in underlay mode. (default false)")
103104
argDefaultExcludeIps = pflag.String("default-exclude-ips", "", "Exclude ips in default switch (default gateway address)")
104105

106+
argDefaultU2OInterconnection = pflag.Bool("default-u2o-interconnection", false, "usage for underlay to overlay interconnection")
107+
105108
argClusterRouter = pflag.String("cluster-router", util.DefaultVpc, "The router name for cluster router")
106109
argNodeSwitch = pflag.String("node-switch", "join", "The name of node gateway switch which help node to access pod network")
107110
argNodeSwitchCIDR = pflag.String("node-switch-cidr", "100.64.0.0/16", "The cidr for node switch")
@@ -168,6 +171,7 @@ func ParseFlags() (*Configuration, error) {
168171
DefaultGateway: *argDefaultGateway,
169172
DefaultGatewayCheck: *argDefaultGatewayCheck,
170173
DefaultLogicalGateway: *argDefaultLogicalGateway,
174+
DefaultU2OInterconnection: *argDefaultU2OInterconnection,
171175
DefaultExcludeIps: *argDefaultExcludeIps,
172176
ClusterRouter: *argClusterRouter,
173177
NodeSwitch: *argNodeSwitch,

pkg/controller/init.go

+14
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,13 @@ func (c *Controller) initDefaultLogicalSwitch() error {
137137
}
138138
if c.config.NetworkType == util.NetworkTypeVlan {
139139
defaultSubnet.Spec.Vlan = c.config.DefaultVlanName
140+
if c.config.DefaultLogicalGateway && c.config.DefaultU2OInterconnection {
141+
err = fmt.Errorf("logicalGateway and u2oInterconnection can't be opened at the same time")
142+
klog.Error(err)
143+
return err
144+
}
140145
defaultSubnet.Spec.LogicalGateway = c.config.DefaultLogicalGateway
146+
defaultSubnet.Spec.U2OInterconnection = c.config.DefaultU2OInterconnection
141147
}
142148

143149
_, err = c.config.KubeOvnClient.KubeovnV1().Subnets().Create(context.Background(), &defaultSubnet, metav1.CreateOptions{})
@@ -304,6 +310,14 @@ func (c *Controller) InitIPAM() error {
304310
if err := c.ipam.AddOrUpdateSubnet(subnet.Name, subnet.Spec.CIDRBlock, subnet.Spec.ExcludeIps); err != nil {
305311
klog.Errorf("failed to init subnet %s: %v", subnet.Name, err)
306312
}
313+
314+
u2oInterconnName := fmt.Sprintf(util.U2OInterconnName, subnet.Spec.Vpc, subnet.Name)
315+
u2oInterconnLrpName := fmt.Sprintf("%s-%s", subnet.Spec.Vpc, subnet.Name)
316+
if subnet.Status.U2OInterconnectionIP != "" {
317+
if _, _, _, err = c.ipam.GetStaticAddress(u2oInterconnName, u2oInterconnLrpName, subnet.Status.U2OInterconnectionIP, "", subnet.Name, true); err != nil {
318+
klog.Errorf("failed to init subnet u2o interonnection ip to ipam %v", subnet.Name, err)
319+
}
320+
}
307321
}
308322

309323
result, err := c.ovnLegacyClient.CustomFindEntity("logical_switch_port", []string{"name"}, `external-ids:vendor{<}""`)

pkg/controller/ip.go

+5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package controller
22

33
import (
4+
"github.com/kubeovn/kube-ovn/pkg/util"
45
"k8s.io/klog/v2"
6+
"strings"
57

68
kubeovnv1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1"
79
)
@@ -12,6 +14,9 @@ func (c *Controller) enqueueAddOrDelIP(obj interface{}) {
1214
}
1315
ipObj := obj.(*kubeovnv1.IP)
1416
klog.V(3).Infof("enqueue update status subnet %s", ipObj.Spec.Subnet)
17+
if strings.HasPrefix(ipObj.Name, util.U2OInterconnName[0:19]) {
18+
return
19+
}
1520
c.updateSubnetStatusQueue.Add(ipObj.Spec.Subnet)
1621
for _, as := range ipObj.Spec.AttachSubnets {
1722
klog.V(3).Infof("enqueue update status subnet %s", as)

pkg/controller/node.go

+3
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,9 @@ func (c *Controller) createOrUpdateCrdIPs(podName, ip, mac, subnetName, ns, node
602602
if subnetName == c.config.NodeSwitch {
603603
key = nodeName
604604
ipName = fmt.Sprintf("node-%s", nodeName)
605+
} else if strings.HasPrefix(podName, util.U2OInterconnName[0:19]) {
606+
key = podName
607+
ipName = podName
605608
} else {
606609
key = podName
607610
ipName = ovs.PodNameToPortName(podName, ns, providerName)

0 commit comments

Comments
 (0)