All Products
Search
Document Center

Elastic Container Instance:Assign an IPv6 address to an Elastic Container Instance-based pod

Last Updated:Feb 19, 2024

Elastic container instances (pods) support IPv4 and IPv6 addresses. Compared with IPv4, IPv6 provides more IP addresses. This topic describes how to assign an IPv6 address to a pod.

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 pods:

  • You can assign only one IPv6 address to a pod.

  • 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.

Prerequisites

IPv6 CIDR blocks are enabled for the virtual private cloud (VPC) in which the pod resides and for the vSwitch to which the pod is connected. For more information, see Enable IPv6 for a VPC and Enable IPv6 for a vSwitch.

Configuration description

In scenarios in which Kubernetes is involved, 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

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:

  • If the billing method for the Internet bandwidth of the IPv6 gateway is pay-by-bandwidth, the Internet bandwidth of the IPv6 address ranges from 1 to 2,000 Mbit/s.

  • If the billing method for the Internet bandwidth of the IPv6 gateway is pay-by-traffic, the Internet bandwidth of the IPv6 address ranges from 1 to 1000 Mbit/s.

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.

Important
  • 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

After you create a pod, you can run the kubectl describe pod command to view the details of the pod. In the returned annotation, you can obtain the IPv6 address of the pod from the k8s.aliyun.com/allocated-ipv6Address field.