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
Constraint |
Tunnel Network |
VPC Network |
Cloud Native 2.0 Network |
---|---|---|---|
Supported versions |
All versions |
Clusters of v1.19.10 and later |
Clusters of v1.19.10 and later |
Supported runtime types |
Only regular containers (runC as the container runtime) are supported. Secure containers (Kata Containers as the container runtime) are not supported. |
||
Supported pod types |
Only non-HostNetwork pods |
||
Supported scenarios |
Inter-pod access, pods accessing nodes, and pods accessing services |
||
Constraints |
None |
None |
|
Value range of rate limit |
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. |
Procedure
- 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
- Create a 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