Pods in Alibaba Cloud Container Compute Service (ACS) clusters support both IPv4 and IPv6. Assign an IPv6 address to a pod by adding annotations to the pod metadata. Optionally, configure public Internet bandwidth for that address.
Background information
IPv4 addresses are widely used, but the limited IPv4 address space restricts the development of the Internet. IPv6 addresses resolve this address space issue and allow more types of devices to access the Internet. For more information, see What is an IPv6 gateway?.
Limitations
-
One address per pod: Each pod supports only one IPv6 address.
-
Resource specifications required: You can only assign IPv6 addresses to pods that have explicit vCPU and memory resource specifications.
Prerequisites
Before you begin, make sure you have:
-
An ACS cluster with IPv6 dual-stack enabled. See Create an ACS cluster
Annotations
Add annotations to the pod metadata to assign an IPv6 address and, optionally, configure Internet bandwidth for that address.
| Annotation | Example value | Required | Description |
|---|---|---|---|
network.alibabacloud.com/enable-ipv6 |
"true" |
Yes | Assigns an IPv6 address to the pod. |
network.alibabacloud.com/ipv6-bandwidth-enable |
"true" |
No | Enables public Internet access over IPv6 for the pod. Set to "true" if the pod needs to send or receive traffic over the public Internet using its IPv6 address. |
network.alibabacloud.com/ipv6-bandwidth |
100M |
No | Sets the peak Internet bandwidth for the IPv6 address, in Mbit/s. Valid ranges depend on the IPv6 gateway billing method: pay-by-bandwidth allows 1–2,000 Mbit/s; pay-by-traffic allows 1–1,000 Mbit/s. If omitted when ipv6-bandwidth-enable is "true", the bandwidth defaults to the maximum supported by the IPv6 gateway. |
Add annotations to the pod metadata section, not the top-level Deployment metadata. For a Deployment, place them under spec.template.metadata.annotations. Annotations only take effect when a pod is created — adding or modifying them on an existing pod has no effect.
Assign an IPv6 address to a pod
-
Create a file named
nginx.yamlwith the following content:apiVersion: apps/v1 kind: Deployment metadata: name: nginx labels: app: nginx spec: replicas: 2 selector: matchLabels: app: nginx template: metadata: name: nginx-test labels: app: nginx annotations: network.alibabacloud.com/enable-ipv6: "true" # Assign an IPv6 address to the pod. network.alibabacloud.com/ipv6-bandwidth-enable: "true" # Enable public Internet access over IPv6. network.alibabacloud.com/ipv6-bandwidth: 100M # Set peak Internet bandwidth to 100 Mbit/s. spec: containers: - name: nginx image: registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latest ports: - containerPort: 80 -
Deploy the Deployment:
kubectl apply -f nginx.yaml -
Verify that an IPv6 address was assigned to the pod:
kubectl describe pod nginx-xxxxx-xxxxx | grep ipv6-addressThe output shows the assigned IPv6 address in the
network.alibabacloud.com/allocated-ipv6-addressannotation:network.alibabacloud.com/allocated-ipv6-address: 2408:4005:317:301:c870:xxxx:xxxx:xxxxIf the annotation does not appear, check that:
-
The ACS cluster has IPv6 dual-stack enabled.
-
The pod was created (not updated) with the
network.alibabacloud.com/enable-ipv6: "true"annotation.
-