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

bandwidth limit doesn't work #70014

Closed
liuxu623 opened this issue Oct 19, 2018 · 9 comments · Fixed by #70149
Closed

bandwidth limit doesn't work #70014

liuxu623 opened this issue Oct 19, 2018 · 9 comments · Fixed by #70149
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/network Categorizes an issue or PR as relevant to SIG Network.

Comments

@liuxu623
Copy link
Contributor

liuxu623 commented Oct 19, 2018

Is this a BUG REPORT or FEATURE REQUEST?:
/kind bug
What happened:
bandwidth limit doesn't work
What you expected to happen:
bandwidth limit work
How to reproduce it (as minimally and precisely as possible):
https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/#support-traffic-shaping

apiVersion: v1
kind: Pod
metadata:
  name: test
  annotations:
    kubernetes.io/ingress-bandwidth: 1M
    kubernetes.io/egress-bandwidth: 1M
spec:
  containers:
  - name: test
    image: nginx:1.13
Failed create pod sandbox: rpc error: code = Unknown desc = failed to set up sandbox container "4df4f85bbe21bf7e1696d07aae18b544f9ff4e0010d0da14cd503fbe071582a6" network for pod "test": NetworkPlugin cni failed to set up pod "test_default" network: if rate is set, burst must also be set

Anything else we need to know?:
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/dockershim/network/cni/cni.go#L378-L385

if ingress != nil {
    bandwidthParam.IngressRate = int(ingress.Value() / 1000)
    bandwidthParam.IngressBurst = 0 // default to no limit
}
if egress != nil {
    bandwidthParam.EgressRate = int(egress.Value() / 1000)
    bandwidthParam.EgressBurst = 0 // default to no limit
}

https://github.com/containernetworking/plugins/blob/master/plugins/meta/bandwidth/main.go#L110-L113

case burst == 0 && rate != 0:
    return fmt.Errorf("if rate is set, burst must also be set")
case rate == 0 && burst != 0:
    return fmt.Errorf("if burst is set, rate must also be set")

Environment:

  • Kubernetes version (use kubectl version): v1.12.1
  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release): Debian 8
  • Kernel (e.g. uname -a): 4.9.0-0.bpo.6-amd64
  • Install tools:
  • Others:
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 19, 2018
@liuxu623
Copy link
Contributor Author

/sig network

@k8s-ci-robot k8s-ci-robot added sig/network Categorizes an issue or PR as relevant to SIG Network. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 19, 2018
anfernee added a commit to anfernee/kubernetes that referenced this issue Oct 23, 2018
@zyy17
Copy link

zyy17 commented Oct 29, 2018

@liuxu623 You can check #67438.

@m1093782566
Copy link
Contributor

Does #70149 work for you?

@zyy17
Copy link

zyy17 commented Nov 15, 2018

Why ingress/egress value need to divide 1000 to get the rate ?

if ingress != nil {
    bandwidthParam.IngressRate = int(ingress.Value() / 1000)
    bandwidthParam.IngressBurst = 0 // default to no limit
}
if egress != nil {
    bandwidthParam.EgressRate = int(egress.Value() / 1000)
    bandwidthParam.EgressBurst = 0 // default to no limit
}

I think it is the same unit ( bps, bit per second).

@m1093782566

@dongeunsuh
Copy link

Hi, I'm having the same issue while testing traffic shaping feature. Is there any sample yaml file for PODs that limits the bandwidth? (one in https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/#support-traffic-shaping seems not working)

@Alan01252
Copy link

Alan01252 commented Dec 27, 2018

The problem appears to be that the conversion doesn't take into account the suffix used in the annotation.

For example the config

      annotations:
        kubernetes.io/ingress-bandwidth: "500M"
        kubernetes.io/egress-bandwidth: "500M"

Causes a tbf to be generated as below:

qdisc tbf 1: dev cali3fa6073a780 root refcnt 2 rate 500Kbit burst 10737417b lat 4123.2s
qdisc ingress ffff: dev cali3fa6073a780 parent ffff:fff1 ----------------
qdisc tbf 1: dev 576e root refcnt 2 rate 500Kbit burst 10737417b lat 4123.2s

I've tested that this then limits the traffic to the pod as expected.

@m1093782566
Copy link
Contributor

m1093782566 commented Dec 28, 2018

Yeah, seems you got the key @Alan01252

BTW, what network plugin are you using?

@wsszh
Copy link

wsszh commented Mar 1, 2019

@m1093782566 Hello, I got the same problem as @Alan01252 said. Have you solved this problem?

if ingress != nil {
    bandwidthParam.IngressRate = int(ingress.Value() / 1000)
}
if egress != nil {
    bandwidthParam.EgressRate = int(egress.Value() / 1000)
}

I want to ask the same question as @GhostComputing asked. Why ingress/egress value needs to divide 1000 to get the rate? Because of it, I have to set the annotation below to limit ingress/egress bandwidth to 1Mbps:

apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubernetes.io/ingress-bandwidth: 1000M
    kubernetes.io/egress-bandwidth: 1000M

Then, run the command

tc qdisc show

I can get the expected result:

qdisc tbf 1: dev cali72f390115b5 root refcnt 2 rate 1Mbit burst 27917286b lat 1924.2s 
qdisc ingress ffff: dev cali72f390115b5 parent ffff:fff1 ---------------- 
qdisc tbf 1: dev e544 root refcnt 2 rate 1Mbit burst 27917286b lat 1924.2s

However, if I set the annotation following the document:

apiVersion: v1
kind: Pod
metadata:
  annotations:
    kubernetes.io/ingress-bandwidth: 1M
    kubernetes.io/egress-bandwidth: 1M

Then run the command:

tc qdisc show

The rate is only 1Kbit as shown below!

qdisc tbf 1: dev cali72f390115b5 root refcnt 2 rate 1Kbit burst 21473b lat 4123.2s 
qdisc ingress ffff: dev cali72f390115b5 parent ffff:fff1 ---------------- 
qdisc tbf 1: dev 831e root refcnt 2 rate 1Kbit burst 21473b lat 4123.2s 

@ggaaooppeenngg
Copy link
Contributor

Why bandwidth is divided by 1000?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/network Categorizes an issue or PR as relevant to SIG Network.
Projects
None yet
8 participants