Skip to content

Commit e3bf65a

Browse files
committed
simple vip
Signed-off-by: zbb88888 <jmdxjsjgcxy@gmail.com>
1 parent f29c6c8 commit e3bf65a

3 files changed

Lines changed: 4 additions & 45 deletions

File tree

dist/images/install.sh

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,12 +2472,6 @@ spec:
24722472
type: string
24732473
mac:
24742474
type: string
2475-
pv4ip:
2476-
type: string
2477-
pv6ip:
2478-
type: string
2479-
pmac:
2480-
type: string
24812475
selector:
24822476
type: array
24832477
items:
@@ -2518,12 +2512,6 @@ spec:
25182512
type: string
25192513
v6ip:
25202514
type: string
2521-
parentV4ip:
2522-
type: string
2523-
parentMac:
2524-
type: string
2525-
parentV6ip:
2526-
type: string
25272515
selector:
25282516
type: array
25292517
items:

pkg/apis/kubeovn/v1/vip.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ type VipSpec struct {
3535
V4ip string `json:"v4ip"`
3636
V6ip string `json:"v6ip"`
3737
MacAddress string `json:"macAddress"`
38-
ParentV4ip string `json:"parentV4ip"`
39-
ParentV6ip string `json:"parentV6ip"`
40-
ParentMac string `json:"parentMac"`
4138
Selector []string `json:"selector"`
4239
AttachSubnets []string `json:"attachSubnets"`
4340
}
@@ -54,9 +51,6 @@ type VipStatus struct {
5451
V4ip string `json:"v4ip" patchStrategy:"merge"`
5552
V6ip string `json:"v6ip" patchStrategy:"merge"`
5653
Mac string `json:"mac" patchStrategy:"merge"`
57-
Pv4ip string `json:"pv4ip" patchStrategy:"merge"`
58-
Pv6ip string `json:"pv6ip" patchStrategy:"merge"`
59-
Pmac string `json:"pmac" patchStrategy:"merge"`
6054
}
6155

6256
func (s *VipStatus) Bytes() ([]byte, error) {

pkg/controller/vip.go

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ func (c *Controller) enqueueUpdateVirtualIP(oldObj, newObj any) {
3333
key := cache.MetaObjectToName(newVip).String()
3434
if !newVip.DeletionTimestamp.IsZero() ||
3535
oldVip.Spec.MacAddress != newVip.Spec.MacAddress ||
36-
oldVip.Spec.ParentMac != newVip.Spec.ParentMac ||
37-
oldVip.Spec.ParentV4ip != newVip.Spec.ParentV4ip ||
3836
oldVip.Spec.V4ip != newVip.Spec.V4ip ||
3937
oldVip.Spec.V6ip != newVip.Spec.V6ip {
4038
klog.Infof("enqueue update vip %s", key)
@@ -100,7 +98,6 @@ func (c *Controller) handleAddVirtualIP(key string) error {
10098
klog.Error(err)
10199
return err
102100
}
103-
var parentV4ip, parentV6ip, parentMac string
104101
if vip.Spec.Type == util.SwitchLBRuleVip {
105102
// create a lsp use subnet gw mac, and set it option as arp_proxy
106103
lrpName := fmt.Sprintf("%s-%s", subnet.Spec.Vpc, subnet.Name)
@@ -128,16 +125,7 @@ func (c *Controller) handleAddVirtualIP(key string) error {
128125
return err
129126
}
130127
}
131-
if vip.Spec.ParentMac != "" {
132-
if vip.Spec.Type == util.SwitchLBRuleVip {
133-
err = errors.New("invalid usage of vip")
134-
klog.Error(err)
135-
return err
136-
}
137-
parentV4ip = vip.Spec.ParentV4ip
138-
parentV6ip = vip.Spec.ParentV6ip
139-
parentMac = vip.Spec.ParentMac
140-
}
128+
141129
if vip.Spec.Type == util.KubeHostVMVip {
142130
// k8s host network pod vm use vip for its nic ip
143131
klog.Infof("create lsp for host network pod vm nic ip %s", vip.Name)
@@ -148,7 +136,7 @@ func (c *Controller) handleAddVirtualIP(key string) error {
148136
return err
149137
}
150138
}
151-
if err = c.createOrUpdateVipCR(key, vip.Spec.Namespace, subnet.Name, v4ip, v6ip, mac, parentV4ip, parentV6ip, parentMac); err != nil {
139+
if err = c.createOrUpdateVipCR(key, vip.Spec.Namespace, subnet.Name, v4ip, v6ip, mac); err != nil {
152140
klog.Errorf("failed to create or update vip '%s', %v", vip.Name, err)
153141
return err
154142
}
@@ -207,10 +195,8 @@ func (c *Controller) handleUpdateVirtualIP(key string) error {
207195
}
208196
// should update
209197
if vip.Status.Mac == "" {
210-
// TODO:// add vip in its parent port aap list
211198
if err = c.createOrUpdateVipCR(key, vip.Spec.Namespace, vip.Spec.Subnet,
212-
vip.Spec.V4ip, vip.Spec.V6ip, vip.Spec.MacAddress,
213-
vip.Spec.ParentV4ip, vip.Spec.ParentV6ip, vip.Spec.MacAddress); err != nil {
199+
vip.Spec.V4ip, vip.Spec.V6ip, vip.Spec.MacAddress); err != nil {
214200
klog.Error(err)
215201
return err
216202
}
@@ -336,7 +322,7 @@ func (c *Controller) handleUpdateVirtualParents(key string) error {
336322
return nil
337323
}
338324

339-
func (c *Controller) createOrUpdateVipCR(key, ns, subnet, v4ip, v6ip, mac, pV4ip, pV6ip, pmac string) error {
325+
func (c *Controller) createOrUpdateVipCR(key, ns, subnet, v4ip, v6ip, mac string) error {
340326
vipCR, err := c.virtualIpsLister.Get(key)
341327
if err != nil {
342328
if k8serrors.IsNotFound(err) {
@@ -355,9 +341,6 @@ func (c *Controller) createOrUpdateVipCR(key, ns, subnet, v4ip, v6ip, mac, pV4ip
355341
V4ip: v4ip,
356342
V6ip: v6ip,
357343
MacAddress: mac,
358-
ParentV4ip: pV4ip,
359-
ParentV6ip: pV6ip,
360-
ParentMac: pmac,
361344
},
362345
}, metav1.CreateOptions{}); err != nil {
363346
err := fmt.Errorf("failed to create crd vip '%s', %w", key, err)
@@ -377,17 +360,11 @@ func (c *Controller) createOrUpdateVipCR(key, ns, subnet, v4ip, v6ip, mac, pV4ip
377360
vip.Spec.V4ip = v4ip
378361
vip.Spec.V6ip = v6ip
379362
vip.Spec.MacAddress = mac
380-
vip.Spec.ParentV4ip = pV4ip
381-
vip.Spec.ParentV6ip = pV6ip
382-
vip.Spec.ParentMac = pmac
383363

384364
vip.Status.Ready = true
385365
vip.Status.V4ip = v4ip
386366
vip.Status.V6ip = v6ip
387367
vip.Status.Mac = mac
388-
vip.Status.Pv4ip = pV4ip
389-
vip.Status.Pv6ip = pV6ip
390-
vip.Status.Pmac = pmac
391368
vip.Status.Type = vip.Spec.Type
392369
if _, err := c.config.KubeOvnClient.KubeovnV1().Vips().Update(context.Background(), vip, metav1.UpdateOptions{}); err != nil {
393370
err := fmt.Errorf("failed to update vip '%s', %w", key, err)

0 commit comments

Comments
 (0)