-
Notifications
You must be signed in to change notification settings - Fork 39.9k
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
Adding traffic shaping support for CNI network driver #63194
Conversation
/assign @thockin |
This looks OK, but I'll need someone to really try it out. What can we do about testing? |
My team member @Lion-Wei is working on adding some e2e test cases for this feature. |
/assign @rramkumar1 Can you take a look when you have chance? :) Thanks! |
/lgtm though as noted we should really have some tests too |
@@ -68,6 +69,21 @@ type cniPortMapping struct { | |||
HostIP string `json:"hostIP"` | |||
} | |||
|
|||
// cniBandwidthEntry maps to the standard CNI bandwidth Capability | |||
// see: https://github.com/containernetworking/cni/blob/master/CONVENTIONS.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably also mention:
https://github.com/containernetworking/plugins/blob/master/plugins/meta/bandwidth/README.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@dcbw ,I think we better have some e2e test case about |
As @Lion-Wei mentioned, my team has been working on adding e2e tests for some days but we find
So, can we let this PR in first and then update the jobs in kubernetes/test-infra? My team will continue to work on it. BTW, the functionalities of cni bandwidth plugins is already being tested in |
// cniBandwidthEntry maps to the standard CNI bandwidth Capability | ||
// see: https://github.com/containernetworking/cni/blob/master/CONVENTIONS.md | ||
type cniBandwidthEntry struct { | ||
// IngressRate is the bandwidth rate in Kbps for traffic through container. 0 for no limit. If ingressRate is set, ingressBurst must also be set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bug in the CNI documentation; it is actually bits per second.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
bandwidthParam := cniBandwidthEntry{} | ||
if ingress != nil { | ||
bandwidthParam.IngressRate = int(ingress.Value() / 1000) | ||
bandwidthParam.IngressBurst = int(ingress.Value() / 1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This value should be hard-coded to 1600 bits - it's the linux TC default and is what kubenet uses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Thanks!
if ingress != nil || egress != nil { | ||
bandwidthParam := cniBandwidthEntry{} | ||
if ingress != nil { | ||
bandwidthParam.IngressRate = int(ingress.Value() / 1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation was wrong; the units are bits per second.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks!
bandwidthParam.IngressBurst = int(ingress.Value() / 1000) | ||
} | ||
if egress != nil { | ||
bandwidthParam.EgressRate = int(egress.Value() / 1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bits per second here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
if egress != nil { | ||
bandwidthParam.EgressRate = int(egress.Value() / 1000) | ||
bandwidthParam.EgressBurst = int(egress.Value() / 1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be the default of 1600
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
// see: https://github.com/containernetworking/cni/blob/master/CONVENTIONS.md | ||
type cniBandwidthEntry struct { | ||
// IngressRate is the bandwidth rate in Kbps for traffic through container. 0 for no limit. If ingressRate is set, ingressBurst must also be set | ||
IngressRate int `json:"ingressRate"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these fields should have omitEmpty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
I did a manual end-to-end test as part of #64445 and found some bugs - left some comments. |
/lgtm |
/hold cancel |
does support change bandwith dynamic when pods in runtime ? |
Currently, it doesn't support - we configure bandwidth limit in pod start up. I think we can support it if we get better consensus. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dcbw, Lion-Wei, m1093782566, thockin The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
THANKS @thockin |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it:
Adding traffic shaping support for CNI network driver - it's also a sub-task of kubenet deprecation work.
Design document is available here: kubernetes/community#1893
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
/cc @freehan @jingax10 @caseydavenport @dcbw
/sig network
/sig node
Release note: