Elastic Container Instance (pod) supports IPv4 and IPv6 addresses. Compared with IPv4, IPv6 provides more IP addresses. This topic describes how to assign an IPv6 address to an elastic container instance.
Background information
IPv4 addresses are widely used. However, the limited number of IPv4 addresses restricts the development of the Internet. Compared with IPv4 addresses, IPv6 addresses are more sufficient and allow more types of devices to access the Internet. For more information, see What is an IPv6 gateway?
The following limits apply when you assign IPv6 addresses to elastic container instances:
You can assign only one IPv6 address to an elastic container instance.
All elastic container instances that you create by specifying number of vCPUs and memory size can be assigned IPv6 addresses. For elastic container instances that you create by specifying instance types of Elastic Compute Service (ECS), make sure that the ECS instance types that you specify support IPv6 addresses before you assign IPv6 addresses to elastic container instances. For information about whether an ECS instance type supports IPv6 addresses, see Overview of instance families.
Before you begin
Make sure that the following operations are complete before you assign an IPv6 address:
Enable IPv6 CIDR blocks for the virtual private cloud (VPC) in which the elastic container instance resides and for the vSwitch to which the elastic container instance is connected. For more information, see Enable IPv6 for a VPC and Enable IPv6 for a vSwitch.
Optional. Create an IPv6 gateway. For more information, see Create and manage an IPv6 gateway.
IPv6 gateways are available in the following editions: Free Edition, Enterprise Edition, and Enhanced Enterprise Edition. Different editions of IPv6 gateways have different capabilities. After you enable an IPv6 CIDR block for a VPC, the system automatically creates a Free Edition IPv6 gateway for the VPC. You can create IPv6 gateways of different editions based on your business requirements.
If you want to use an IPv6 address to communicate over the Internet, you must enable IPv6 Internet bandwidth for the IPv6 gateway. For more information, see Enable and manage IPv6 Internet bandwidth.
Configuration description
In scenarios in which Kubernetes is used, you can add an annotation to the metadata of the pod to assign an IPv6 address to the pod. Then, you can configure and enable the Internet bandwidth of the IPv6 address. The following table describes the annotations.
Annotation | Example value | Required | Description |
k8s.aliyun.com/eci-enable-ipv6 | "true" | Yes | Specifies whether to assign an IPv6 address to the pod. |
k8s.aliyun.com/eci-ipv6-bandwidth-enable | "true" | No | Specifies whether to enable Internet access over IPv6 addresses for the pod. |
k8s.aliyun.com/eci-ipv6-bandwidth | 200 | No | Specifies the peak Internet bandwidth of the IPv6 address. Valid values:
Note If you do not configure this annotation when you enable Internet access over IPv6 addresses for a pod, the default Internet bandwidth of the IPv6 address that is assigned to the pod is equal to the maximum Internet bandwidth that is supported by the IPv6 gateway. |
Annotations must be added to the metadata in the configuration file of the pod. For example, when you create a Deployment, you must add annotations in the spec.template.metadata section.
To use features of Elastic Container Instance, you can add annotations only when you create Elastic Container Instance-based pods. If you add or modify annotations when you update pods, these annotations do not take effect.
Example:
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 addresses for the pod.
k8s.aliyun.com/eci-ipv6-bandwidth: 100M # Configures the peak Internet bandwidth of the IPv6 address.
spec:
containers:
- name: nginx
image: registry.cn-shanghai.aliyuncs.com/eci_open/nginx:1.14.2
ports:
- containerPort: 80