Set maximum inbound and outbound bandwidth for Elastic Container Instance (ECI)-based pods to ensure network stability, security, and quality of service (QoS), and prevent any single pod from consuming excessive bandwidth.
How it works
Bandwidth limits are applied via annotations on the pod metadata. The two supported annotations are:
| Annotation | Direction | Description |
|---|---|---|
kubernetes.io/ingress-bandwidth | Inbound | Maximum inbound (ingress) bandwidth |
kubernetes.io/egress-bandwidth | Outbound | Maximum outbound (egress) bandwidth |
Unit conversion: Annotation values use storage-style units (B, K, KB, M, MB, G, GB, T, or TB). ECI interprets the value as bytes per second (Bps) and converts it to a network bandwidth rate. For example, 40M is treated as 40 MBps, which equals 320 Mbit/s. If you omit the unit, ECI defaults to B (bytes).
Bandwidth annotations only take effect when a pod is created. If you add or modify these annotations on an existing pod, the changes are ignored.
Set bandwidth limits on a pod
Add the bandwidth annotations in the metadata.annotations section of your pod spec. For a Deployment, place the annotations in spec.template.metadata.annotations — not in the top-level metadata of the Deployment itself.
The following example creates a Deployment with a 40 M ingress limit and a 10 M egress limit:
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
labels:
app: test
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
name: nginx-test
labels:
app: nginx
alibabacloud.com/eci: "true"
annotations:
kubernetes.io/ingress-bandwidth: 40M # Limit inbound bandwidth to 320 Mbit/s
kubernetes.io/egress-bandwidth: 10M # Limit outbound bandwidth of the pod
spec:
containers:
- name: nginx
image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
ports:
- containerPort: 80Limitations
| Limitation | Details |
|---|---|
| Annotations take effect at creation only | Adding or modifying kubernetes.io/ingress-bandwidth or kubernetes.io/egress-bandwidth on an existing pod has no effect. |
| Annotation placement | For Deployments and other workload controllers, always add bandwidth annotations in spec.template.metadata.annotations. Annotations in the top-level Deployment metadata do not affect the pods. |