Help Center/ Cloud Container Instance (CCI)/ Best Practices/ Workload Management/ Configuring Multiple Network Interfaces and EIPs for a Pod
Updated on 2025-08-12 GMT+08:00

Configuring Multiple Network Interfaces and EIPs for a Pod

Scenario

When a pod needs multiple network interfaces to manage network traffic, you can configure them for the pod on CCI. This feature allows you to create multiple networks in the same namespace and configure the network and EIP used by each network interface in a pod annotation.

Feature Description

  • When multiple networks are created, you must specify a network in the namespace as the default network (by setting spec.defaultNetwork to true). If there is only one network in the namespace, the network is identified as the default network.
  • If there are multiple networks in a namespace, the default network cannot be changed to a non-default network.
  • If there are multiple networks in a namespace, you can delete the default network configuration. However, you need to reconfigure a new default network after the deletion. Otherwise, the network function is abnormal.
  • When multiple networks are created, the subnets of the networks cannot overlap, and the subnets configured for all networks must be in the same VPC.
  • Deployments cannot have multiple network interfaces and EIPs. Only pods can have multiple network interfaces and EIPs.
  • You can configure multiple network interfaces and EIPs for pods through the yangtse.io/multi-eip-ids or k8s.v1.cni.cncf.io/networks annotation. The two annotations cannot be configured at the same time.
  • Only general-computing-lite pods can have multiple network interfaces and EIPs.
  • A pod can have a maximum of five network interfaces.
  • If a pod is configured with multiple network interfaces, only the IP address of the primary network interface is displayed. (The IP address displayed in status.podIP and status.podIPs is the IP address of the first network interface.)

Constraints

  • Pods with multiple network interfaces may take a little longer to start. Plan and use the network interfaces appropriately.
  • If there are multiple network interfaces and EIPs, only IPv4 addresses are supported.
  • If a pod is configured with multiple network interfaces and EIPs, the primary network interface is used by default. You need to synchronize the special configurations (such as EIP access to the public network and security group network segment bypass) of other network interfaces to the primary network interface. If the special configurations are not synchronized, there may be problems such as image pull failure and volume mounting failure.
  • If a pod is configured with multiple network interfaces and EIPs, the cci.io/image-snapshot-create-if-not-present annotation cannot be used for automatic image snapshot creation.
  • If a pod is configured with multiple network interfaces and EIPs, the annotations for configuring a single EIP (including yangtse.io/eip-bandwidth-id, yangtse.io/eip-bandwidth-size, yangtse.io/eip-network-type, yangtse.io/eip-charge-mode, yangtse.io/eip-bandwidth-name, yangtse.io/pod-with-eip and yangtse.io/eip-id) are not supported.
  • If IP addresses in the subnet in the primary network are used up, a non-primary network will not be selected.

Procedure

  1. Call the CCI API to set the default network and create multiple networks.
    apiVersion: yangtse/v2
    kind: Network
    metadata:
      name: test-network
      namespace: test
    spec:
      defaultNetwork: true          // If defaultNetwork is set to true, the network is the default network.
      networkType: underlay_neutron
      subnets:
      - subnetID: ${subnet1}
      - subnetID: ${subnet2}
  2. Log in to the CCI 2.0 console.
  3. In the navigation pane, choose Workloads. On the Pods tab, click Create from YAML.

  4. Define the pod. The following is an example YAML file:

    The k8s.v1.cni.cncf.io/networks field is used as an example. If the yangtse.io/multi-eip-ids field is required, see Table 1.

    kind: Pod
    apiVersion: cci/v2
    metadata:
      name: pod-muti-eip-test
      annotations:
        k8s.v1.cni.cncf.io/networks: '[{"name":"second-network","interface":"eth0"},{"name":"default-network","interface":"eth1"},{"name":"default-network","interface":"eth2"},{"name":"second-network","interface":"eth3"}]'
        resource.cci.io/instance-type: general-computing-lite
        resource.cci.io/pod-size-specs: 0.25_0.5
    spec:
      containers:
        - name: init-myservice
          image: nginx:latest
          ports:
            - containerPort: 80
              protocol: TCP
          resources:
            limits:
              cpu: 250m
              memory: 512Mi
            requests:
              cpu: 250m
              memory: 512Mi
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: Default
      securityContext: {}
      imagePullSecrets:
        - name: imagepull-secret
    Table 1 yangtse.io/multi-eip-ids and k8s.v1.cni.cncf.io/networks description

    Field

    Value Type

    Format

    Description

    Example Value

    yangtse.io/multi-eip-ids

    String

    eip-id1,eip-id2,eip-id3,eip-id4

    • EIP IDs. Use commas (,) to separate multiple IDs. Each EIP ID is unique. The EIPs are not bound to any resources.

    yangtse.io/multi-eip-ids: eip-id1,eip-id2,eip-id3,eip-id4

    k8s.v1.cni.cncf.io/networks

    String

    [

    {

    "name": "second-network",

    "interface": "eth1",

    "eip": {

    "id": "eip-id",

    "bandwidth-size": "5",

    "network-type": "5_g-vm",

    "charge-mode": "bandwidth",

    "bandwidth-name": "eip-myself",

    "bandwidth-id": "bandwidth-id"

    }

    }

    ]

    • name: (optional) The default value is "". If this parameter is not specified, the default network is used. The network must be created in advance.
    • interface: (optional) indicates the name of the network interface. The default value is "". If this parameter is not specified, the network interface name is constructed based on the array sequence. For example, if the first element in the array is eth0, the network interface name is eth0. The network interface names in the pod must be set to eth0 and eth1 in sequence.
    • eip: (optional) indicates the EIP associated with the network interface of the pod. If this parameter is not specified, no EIP needs to be configured for the network interface. A network interface can only be associated with one EIP ID. Multiple network interfaces cannot be associated with the same EIP ID.
    • id: (optional) indicates the ID of an EIP that has not been bound to any resource. If this parameter is not specified, an existing EIP ID is not used. If this parameter is specified, the bandwidth-id, bandwidth-size, bandwidth-name, network-type, and charge-mode parameters become invalid.
    • bandwidth-id: (optional) indicates the ID of a shared bandwidth. If this parameter is specified, EIPs use a shared bandwidth. If this parameter is not specified, dedicated bandwidths are used. If this parameter is specified, the bandwidth-size, bandwidth-name, and charge-mode parameters become invalid.
    • bandwidth-size: (optional) indicates the dedicated bandwidth range, in Mbit/s. The default value is 5. If this parameter is specified, the specified bandwidth range will be used. This parameter is used together with network-type, charge-mode, and bandwidth-name. The bandwidth ranges vary by region. For details, see the EIP console.
    • network-type: (optional) indicates a public IP address. The default value is 5_bgp. If this parameter is specified, an EIP will be assigned. This parameter is used together with bandwidth-size, charge-mode, and bandwidth-name. The types vary by region. For details, see the EIP console. For example, the following types are supported in the CN East-Shanghai1 region:
      • 5_bgp: dynamic BGP
      • 5_sbgp: static BGP
    • charge-mode: (optional) indicates the billing mode. If this parameter is specified, an EIP with the specified billing mode will be assigned. This parameter is used together with bandwidth-size, network-type, and bandwidth-name. The default value varies depending on the region configuration.
      • bandwidth: billed by bandwidth
      • traffic: billed by traffic
    • bandwidth-name: (optional) indicates the name of the dedicated bandwidth. The default value is randomly generated. After this parameter is specified, a dedicated bandwidth with the specified name will be assigned. This parameter is used together with bandwidth-size, network-type, and charge-mode. The following configuration is for your reference:
      • The value can contain 1 to 64 characters and must start and end with a digit or letter. Only digits, letters, underscores (_), hyphens (-), and periods (.) are allowed.
      • Minimum characters: 1
      • Maximum characters: 64

    k8s.v1.cni.cncf.io/networks: [{"name":"default-network","interface":"eth0","eip":{"id":"eip-id"}},{"name":"second-network","interface":"eth1","eip":{"bandwidth-size":"5","network-type":"5_g-vm","charge-mode":"bandwidth","bandwidth-name":"eip-myself"}},{"name":"third-network","interface":"eth2","eip":{"bandwidth-id":"bandwidth-id"}},{"name":"network-no-eip","interface":"eth3"}]

  5. Click OK.