Help Center/ Cloud Container Engine/ Best Practices/ Container/ Configuration Suggestions on Container Network Bandwidth Limit
Updated on 2025-01-08 GMT+08:00

Configuration Suggestions on Container Network Bandwidth Limit

Application Scenarios

Containers on the same node share the host network bandwidth. Limiting the network bandwidth of containers can effectively prevent mutual interference between containers and improve container network stability.

Constraints

The following table lists the bandwidth limitation specifications of pods.

Specifications

Tunnel

VPC

Cloud Native Network 2.0

Supported cluster versions

All versions

Clusters of v1.19.10 and later

Clusters of v1.19.10 and later

Egress bandwidth limitation

Supported

Supported

Supported

Ingress bandwidth limitation

Supported

Supported

Supported

Scenarios where bandwidth limitation is not supported

None

None

  • Pod access to cloud service CIDR blocks such as 100.125.0.0/16
  • Pod health check

Bandwidth limitation range

Only the rate limit in the unit of Mbit/s or Gbit/s is supported, for example, 100 Mbit/s and 1 Gbit/s. The minimum value is 1 Mbit/s and the maximum value is 4.29 Gbit/s.

  • Pod bandwidth limitation applies to regular containers (runC as the container runtime), not secure containers (Kata Containers as the container runtime).
  • Pod bandwidth limitation does not apply to hostNetwork pods.

Procedure

  1. Edit a YAML file for a workload.

    vi deployment.yaml

    Set the network bandwidth for the pod in spec.template.metadata.annotations to limit the network traffic of the container. For details about the network bandwidth limit fields, see Table 1.

    If the parameters are not specified, the network bandwidth is not limited by default.

    An example is as follows:

    apiVersion: apps/v1 
    kind: Deployment 
    metadata: 
      name: nginx 
    spec: 
      replicas: 1 
      selector: 
        matchLabels: 
          app: nginx 
      strategy: 
        type: RollingUpdate 
      template: 
        metadata: 
          labels: 
            app: nginx 
          annotations:
           # Ingress bandwidth
            kubernetes.io/ingress-bandwidth: 100M
           # Egress bandwidth
            kubernetes.io/egress-bandwidth: 1G
        spec: 
          containers: 
          - image: nginx  
            imagePullPolicy: Always 
            name: nginx 
          imagePullSecrets: 
          - name: default-secret
    Table 1 Fields for limiting the network bandwidth of pods

    Field

    Description

    Mandatory

    kubernetes.io/ingress-bandwidth

    Ingress bandwidth for a pod.

    Value range: 1k-1P. If this field is set to a value greater than 32 Gbit/s, the actual ingress bandwidth that a pod can use is 32 Gbit/s.

    No

    kubernetes.io/egress-bandwidth

    Egress bandwidth for a pod.

    Value range: 1k-1P. If this field is set to a value greater than 32 Gbit/s, the actual egress bandwidth that a pod can use is 32 Gbit/s.

    No

  2. Create a workload.

    kubectl create -f deployment.yaml

    Information similar to the following is displayed:

    deployment.apps/nginx created