openyurtio / openyurt

OpenYurt - Extending your native Kubernetes to edge(project under CNCF)

Home Page:https://openyurt.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[feature request]improve discardcloudservice filter in yurthub component

rambohe-ch opened this issue · comments

What would you like to be added:
Because clients on edges nodes can not connect cloud applications through pod ip, so LoadBalancer service for cloud application is discarded in yurthub component in order to make kube-proxy unaware of LoadBalancer service on edge nodes. and only LoadBalancer service with annotation openyurt.io/skip-discard=true will be skipped.
the following are detail codes:

if svc.Spec.Type == v1.ServiceTypeLoadBalancer {
if svc.Annotations[filter.SkipDiscardServiceAnnotation] != "true" {
klog.V(2).Infof("load balancer service(%s) is discarded in StreamResponseFilter of discardCloudServiceFilterHandler", nsName)
return nil
}
}

but in the proposal: https://github.com/openyurtio/openyurt/blob/master/docs/proposals/20231121-high-availability-of-edge-services.md, LoadBalancer service across NodePools will be supported, this means that LoadBalancer service should be aware of on edge nodes.

so we will improve discardcloudservice filter in yurthub component, and only discard LoadBalancer service which has annotation svc.openyurt.io/discard=true, this means that LoadBalancer service will not be discarded by default.

others
/kind feature

@gnunu @JameKeal @YTGhost Do you have any comments?

It seems we first need to add a new annotation svc.openyurt.io/discard=true after line 48 in the following code

SkipDiscardServiceAnnotation = "openyurt.io/skip-discard"

and then we need to modify the following code, discard LoadBalancer service which has svc.openyurt.io/discard=true, instead of which doesn't have openyurt.io/skip-discard=true.
if svc.Spec.Type == v1.ServiceTypeLoadBalancer {
if svc.Annotations[filter.SkipDiscardServiceAnnotation] != "true" {
klog.V(2).Infof("load balancer service(%s) is discarded in StreamResponseFilter of discardCloudServiceFilterHandler", nsName)
return nil
}
}

I have raised a pr to implement the logic described above to fix this issue.

It seems we first need to add a new annotation svc.openyurt.io/discard=true after line 48 in the following code

SkipDiscardServiceAnnotation = "openyurt.io/skip-discard"

and then we need to modify the following code, discard LoadBalancer service which has svc.openyurt.io/discard=true, instead of which doesn't have openyurt.io/skip-discard=true.

if svc.Spec.Type == v1.ServiceTypeLoadBalancer {
if svc.Annotations[filter.SkipDiscardServiceAnnotation] != "true" {
klog.V(2).Infof("load balancer service(%s) is discarded in StreamResponseFilter of discardCloudServiceFilterHandler", nsName)
return nil
}
}

I have raised a pr to implement the logic described above to fix this issue.

@huangchenzhao yes, you're right. by the way, unit tests also should be tuned.