Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance operational efficiency of K8s cluster in user's IDC #2157

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

huangchenzhao
Copy link
Member

What type of PR is this?

/kind feature
/kind design

What this PR does / why we need it:

#2124

Which issue(s) this PR fixes:

Fixes #2156

@huangchenzhao
Copy link
Member Author

It is draft now and will be finished soon.

@huangchenzhao huangchenzhao marked this pull request as ready for review September 30, 2024 15:38
@huangchenzhao huangchenzhao marked this pull request as draft September 30, 2024 15:38
}
m.iptablesManager.addIptablesRules(m.cloudIP, m.apiserverIPs)

podInformer := informerFactory.Core().V1().Pods()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a good idea to list/watch pod for monitoring kube-apiserver IPs, because we want to narrow the permission of informer.

maybe we can use an endpoints(like tenant-kas-svc) for storing the address of kube-apiserver, so we only need to list/watch this endpoints for getting address of kube-apiserver.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@huangchenzhao huangchenzhao force-pushed the locallb branch 2 times, most recently from dc085a7 to 1d57850 Compare October 27, 2024 20:04
Copy link

codecov bot commented Oct 27, 2024

Codecov Report

Attention: Patch coverage is 51.78571% with 27 lines in your changes missing coverage. Please review.

Project coverage is 59.00%. Comparing base (7763e7c) to head (3a4d21e).
Report is 38 commits behind head on master.

Files with missing lines Patch % Lines
cmd/yurthub/app/config/config.go 37.14% 15 Missing and 7 partials ⚠️
cmd/yurthub/app/options/options.go 75.00% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2157      +/-   ##
==========================================
+ Coverage   58.93%   59.00%   +0.06%     
==========================================
  Files         210      211       +1     
  Lines       18968    19105     +137     
==========================================
+ Hits        11179    11273      +94     
- Misses       6707     6745      +38     
- Partials     1082     1087       +5     
Flag Coverage Δ
unittests 59.00% <51.78%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@huangchenzhao huangchenzhao force-pushed the locallb branch 2 times, most recently from 9efea83 to 5157fcf Compare October 28, 2024 08:26
ramdomBalancingProbability := im.getRamdomBalancingProbability(len(ips))
for index, ip := range ips {
// All packets (from kubelet, kubeproxy, pods, etc.) are loadbalanced to multiple addresses of apiservers deployed in daemonset, except packets which are sent to host control plane.
err := im.ipt.Append("nat", "OUTPUT", "! -d", tenantKasService, "-p", "tcp", "-m", "statistic", "--mode", "random", "--probability", strconv.FormatFloat(ramdomBalancingProbability[index], 'f', -1, 64), "-j", "DNAT", "--to-destination", ip)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to add port for the iptables rule, because source port and dest port maybe different.

}

func (im *IptablesManager) updateIptablesRules(tenantKasService string, ips []string) error {
if err := im.cleanIptablesRules(tenantKasService, ips); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ips are changed, the new ips can not be used for finding the old iptables rule, so the old iptables rule will be leaked.

@huangchenzhao huangchenzhao force-pushed the locallb branch 2 times, most recently from 02114bd to a8acacd Compare October 29, 2024 06:57
@huangchenzhao huangchenzhao marked this pull request as ready for review October 29, 2024 17:11
@huangchenzhao
Copy link
Member Author

/rerun

Copy link

@huangchenzhao
Copy link
Member Author

/rerun

@rambohe-ch rambohe-ch added approved approved lgtm lgtm labels Oct 30, 2024
@rambohe-ch
Copy link
Member

/LGTM

@rambohe-ch rambohe-ch merged commit bea50af into openyurtio:master Oct 30, 2024
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved approved lgtm lgtm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OSPP 2024] Enhance operational efficiency of K8s cluster in user's IDC
2 participants