Skip to content

Commit

Permalink
fix(kom): 优化 Pod 关联 Service 功能
Browse files Browse the repository at this point in the history
- 在 LinkedService 方法中增加对空 selector 的判断
- 跳过没有特定 pod selector 的 Service,避免误匹配
  • Loading branch information
weibaohui committed Feb 5, 2025
1 parent 023532f commit d6d8387
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kom/ctl_pod_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ func (p *pod) LinkedService() ([]*v1.Service, error) {
var result []*v1.Service
for _, svc := range services {
serviceLabels := svc.Spec.Selector
//如果为空,标明没有特定的pod selector,则跳过这个svc
if len(serviceLabels) == 0 {
continue
}
// 遍历selector
// serviceLabels中所有的kv,都必须在podLabels中存在,且值相等
if utils.CompareMapContains(serviceLabels, podLabels) {
Expand Down

0 comments on commit d6d8387

Please sign in to comment.