ECI pods support both IPv4 and IPv6. To assign an IPv6 address to a pod, add annotations to the pod's metadata when creating it.
Prerequisites
Before you begin, ensure that you have:
IPv6 CIDR blocks enabled for the virtual private cloud (VPC) in which the pod resides. See Enable IPv6 for a VPC.
IPv6 CIDR blocks enabled for the vSwitch to which the pod is connected. See Enable IPv6 for a vSwitch.
Limitations
One IPv6 address per pod: Each pod can be assigned only one IPv6 address.
Instance type compatibility: All ECI instances created by specifying vCPU count and memory size support IPv6. For instances created by specifying Elastic Compute Service (ECS) instance types, confirm that the selected instance type supports IPv6 before proceeding. See Overview of instance families.
Annotations apply at creation only: ECI annotations take effect only when a pod is created. Adding or modifying annotations during a pod update has no effect.
Annotations
Add annotations to the metadata section of your pod configuration. For a Deployment, add them under spec.template.metadata.annotations.
| Annotation | Example value | Required | Description |
|---|---|---|---|
k8s.aliyun.com/eci-enable-ipv6 | "true" | Yes | Assigns an IPv6 address to the pod |
k8s.aliyun.com/eci-ipv6-bandwidth-enable | "true" | No | Enables Internet access over IPv6 for the pod |
k8s.aliyun.com/eci-ipv6-bandwidth | 200 | No | Sets the peak Internet bandwidth (Mbit/s) for the IPv6 address. Valid range: 1–2,000 Mbit/s (pay-by-bandwidth) or 1–1,000 Mbit/s (pay-by-traffic). If omitted, the bandwidth defaults to the maximum supported by the IPv6 gateway. |
Assign an IPv6 address
Add the required annotation to your pod configuration. The following example creates a Deployment with IPv6 enabled and Internet access configured at 100 Mbit/s.
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: k8s.aliyun.com/eci-enable-ipv6: "true" # Assigns an IPv6 address to the pod. k8s.aliyun.com/eci-ipv6-bandwidth-enable: "true" # Enables Internet access over IPv6. k8s.aliyun.com/eci-ipv6-bandwidth: 100M # Sets the peak Internet bandwidth. spec: containers: - name: nginx image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2 ports: - containerPort: 80Apply the configuration.
kubectl apply -f deployment.yaml
Verify the IPv6 address
After the pod is running, run the following command to view the pod details:
kubectl describe pod <pod-name>Look for the k8s.aliyun.com/allocated-ipv6Address field in the annotations section. It contains the assigned IPv6 address.