All Products
Search
Document Center

Container Compute Service:Assign an IPv6 address to a pod

Last Updated:Nov 04, 2024

Pods in Alibaba Cloud Container Compute Service (ACS) clusters support IPv4 and IPv6 addresses. Compared with IPv4, IPv6 provides larger address space. This topic describes how to assign an IPv6 address to a pod in an ACS cluster.

Background information

IPv4 addresses are widely used, but the limited IPv4 address space restricts the development of the Internet. Compared with IPv4 addresses, IPv6 addresses can resolve the address space issue 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 pods for which you have specified the amount of vCPUs and amount of memory can be assigned IPv6 addresses.

Prerequisites

An ACS cluster is created and IPv6 dual-stack is enabled. For more information, see Create an ACS cluster.

Configuration description

In an ACS cluster, you can add annotations to the metadata of a pod to assign an IPv6 address to the pod and configure and specify Internet bandwidth for the IPv6 address. The following table describes the annotations.

Annotation

Example

Required

Description

.network.alibabacloud.com/enable-ipv6

"true"

Yes

A value of true specifies that an IPv6 address is assigned to the pod.

.network.alibabacloud.com/ipv6-bandwidth-enable

"true"

No

A value of true specifies that IPv6 Internet access is enabled for the pod.

.network.alibabacloud.com/ipv6-bandwidth

100M

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 to the spec.template.metadata section.

  • You can add annotations only when you create pods. If you add or modify annotations when you update pods, these annotations do not take effect.

Example

  1. Create a file named nginx.yaml and copy the following content to the file:

    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 Internet access over IPv6 for the pod.
            network.alibabacloud.com/ipv6-bandwidth: 100M              # Specify the peak Internet bandwidth of the IPv6 address.
        spec:
          containers:
          - name: nginx
            image: registry.cn-hangzhou.aliyuncs.com/acs-sample/nginx:latest
            ports:
            - containerPort: 80
  2. Run the following command to deploy the NGINX service:

    kubectl apply -f nginx.yaml
  3. Run the following command to view the details of the pod and obtain the IPv6 address of the pod.

    kubectl describe pod nginx-xxxxx-xxxxx|grep ipv6-address

    Expected output:

                      network.alibabacloud.com/allocated-ipv6-address: 2408:4005:317:301:c870:xxxx:xxxx:xxxx

    You can view the IPv6 address of the pod in the network.alibabacloud.com/allocated-ipv6Address field.