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.
Notes and Constraints
| Specifications | Tunnel Network | VPC Network | Cloud Native Network 2.0 | VPC + DataPlane V2 | Cloud Native Network 2.0 + DataPlane V2 |
|---|---|---|---|---|---|
| Supported cluster versions | All versions | Clusters v1.19.10 and later | Clusters v1.19.10 and later | Cluster version: v1.27.16-r30, v1.28.15-r20, v1.29.13-r0, v1.30.10-r0, v1.31.6-r0, or later | Clusters v1.34.3-r10 or later |
| Egress bandwidth limitation | Supported | Supported | Supported | Supported | Supported |
| Ingress bandwidth limitation | Supported | Supported | Supported | Supported in clusters v1.28.15-r80, v1.29.15-r40, v1.30.14-r0, v1.32.9-r0, v1.33.7-r0, and later versions | Supported |
| Scenarios where bandwidth limitation is not supported | None | None |
| Mutual access between pods on the host node | None |
| Bandwidth limitation range | The value must be specified in either Mbit/s or Gbit/s, for example, 100 Mbit/s or 1 Gbit/s. The minimum allowable value is 1 Mbit/s. The maximum value is 4.29 Gbit/s for clusters running versions earlier than v1.28.15-r70, v1.29.15-r30, v1.30.14-r30, v1.31.10-r30, v1.32.6-r30, v1.33.5-r20, or v1.34.1-r0. Clusters v1.28.15-r70, v1.29.15-r30, v1.30.14-r30, v1.31.10-r30, v1.32.6-r30, v1.33.5-r20, v1.34.1-r0, and later versions: The minimum value is 1 kbit/s, and the maximum value is 1 Pbit/s. | The minimum value is 1 kbit/s, and the maximum value is 1 Pbit/s. | The minimum value is 1 kbit/s, and the maximum value is 1 Pbit/s. | ||
- eBPF-based bandwidth limiting is available only when DataPlane V2 is enabled in the VPC network. Other network models use TBF qdisc for bandwidth limiting.
- Pod bandwidth limitation applies only to regular containers. Secure containers do not support this feature.
- Pod bandwidth limitation does not apply to hostNetwork pods.
Procedure
- Edit a YAML file for a workload.
vi deployment.yaml
Configure 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-secretTable 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
- Create the workload.
kubectl create -f deployment.yaml
Information similar to the following is displayed:
deployment.apps/nginx created
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot