Skip to content

Commit 490794c

Browse files
authored
simple vip (#5534)
* simple vip Signed-off-by: zbb88888 <jmdxjsjgcxy@gmail.com> * update ns Signed-off-by: zbb88888 <jmdxjsjgcxy@gmail.com> --------- Signed-off-by: zbb88888 <jmdxjsjgcxy@gmail.com>
1 parent 60deab8 commit 490794c

File tree

4 files changed

+18
-43
lines changed

4 files changed

+18
-43
lines changed

charts/kube-ovn-v2/crds/kube-ovn-crd.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,8 +2269,6 @@ spec:
22692269
properties:
22702270
type:
22712271
type: string
2272-
ready:
2273-
type: boolean
22742272
v4ip:
22752273
type: string
22762274
v6ip:

charts/kube-ovn/templates/kube-ovn-crd.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,6 +2261,9 @@ spec:
22612261
served: true
22622262
storage: true
22632263
additionalPrinterColumns:
2264+
- name: Namespace
2265+
type: string
2266+
jsonPath: .spec.namespace
22642267
- name: V4IP
22652268
type: string
22662269
jsonPath: .status.v4ip
@@ -2285,8 +2288,6 @@ spec:
22852288
properties:
22862289
type:
22872290
type: string
2288-
ready:
2289-
type: boolean
22902291
v4ip:
22912292
type: string
22922293
v6ip:

dist/images/install.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,6 +2505,9 @@ spec:
25052505
served: true
25062506
storage: true
25072507
additionalPrinterColumns:
2508+
- name: Namespace
2509+
type: string
2510+
jsonPath: .spec.namespace
25082511
- name: V4IP
25092512
type: string
25102513
jsonPath: .status.v4ip
@@ -3816,21 +3819,21 @@ metadata:
38163819
name: secret-reader-ovn-ipsec
38173820
namespace: kube-system
38183821
rules:
3819-
- apiGroups:
3822+
- apiGroups:
38203823
- ""
3821-
resources:
3824+
resources:
38223825
- "secrets"
38233826
resourceNames:
38243827
- "ovn-ipsec-ca"
3825-
verbs:
3828+
verbs:
38263829
- "get"
38273830
- "list"
38283831
- "watch"
3829-
- apiGroups:
3832+
- apiGroups:
38303833
- "cert-manager.io"
3831-
resources:
3834+
resources:
38323835
- "certificaterequests"
3833-
verbs:
3836+
verbs:
38343837
- "get"
38353838
- "list"
38363839
- "create"

pkg/controller/vip.go

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,6 @@ func (c *Controller) handleUpdateVirtualIP(key string) error {
200200
klog.Error(err)
201201
return err
202202
}
203-
ready := true
204-
if err = c.patchVipStatus(key, vip.Spec.V4ip, ready); err != nil {
205-
klog.Error(err)
206-
return err
207-
}
208203
if err = c.handleAddVipFinalizer(key); err != nil {
209204
klog.Errorf("failed to handle vip finalizer %v", err)
210205
return err
@@ -359,8 +354,11 @@ func (c *Controller) createOrUpdateVipCR(key, ns, subnet, v4ip, v6ip, mac string
359354
}
360355
} else {
361356
vip := vipCR.DeepCopy()
362-
if vip.Status.Mac == "" && mac != "" {
363-
// vip not support to update, just delete and create
357+
if vip.Status.Mac == "" && mac != "" ||
358+
vip.Status.V4ip == "" && v4ip != "" ||
359+
vip.Status.V6ip == "" && v6ip != "" {
360+
// vip spec mac or ip not support to update
361+
// only set once during creation
364362
vip.Spec.Namespace = ns
365363
vip.Spec.V4ip = v4ip
366364
vip.Spec.V6ip = v6ip
@@ -370,6 +368,7 @@ func (c *Controller) createOrUpdateVipCR(key, ns, subnet, v4ip, v6ip, mac string
370368
vip.Status.V6ip = v6ip
371369
vip.Status.Mac = mac
372370
vip.Status.Type = vip.Spec.Type
371+
// TODO:// Ready = true as subnet.Status.Ready
373372
if _, err := c.config.KubeOvnClient.KubeovnV1().Vips().Update(context.Background(), vip, metav1.UpdateOptions{}); err != nil {
374373
err := fmt.Errorf("failed to update vip '%s', %w", key, err)
375374
klog.Error(err)
@@ -407,32 +406,6 @@ func (c *Controller) createOrUpdateVipCR(key, ns, subnet, v4ip, v6ip, mac string
407406
return nil
408407
}
409408

410-
func (c *Controller) patchVipStatus(key, v4ip string, ready bool) error {
411-
oriVip, err := c.virtualIpsLister.Get(key)
412-
if err != nil {
413-
if k8serrors.IsNotFound(err) {
414-
return nil
415-
}
416-
klog.Error(err)
417-
return err
418-
}
419-
vip := oriVip.DeepCopy()
420-
var changed bool
421-
422-
if ready && v4ip != "" && vip.Status.V4ip != v4ip {
423-
vip.Status.V4ip = v4ip
424-
changed = true
425-
}
426-
427-
if changed {
428-
if _, err = c.config.KubeOvnClient.KubeovnV1().Vips().Update(context.Background(), vip, metav1.UpdateOptions{}); err != nil {
429-
klog.Errorf("failed to update status for vip '%s', %v", key, err)
430-
return err
431-
}
432-
}
433-
return nil
434-
}
435-
436409
func (c *Controller) podReuseVip(vipName, portName string, keepVIP bool) error {
437410
// when pod use static vip, label vip reserved for pod
438411
oriVip, err := c.virtualIpsLister.Get(vipName)

0 commit comments

Comments
 (0)