Configuring a Static EIP for a Pod

Application Scenarios

In Cloud Native Network 2.0, static public IP addresses (EIPs) can be assigned to StatefulSets or pods created directly.

Constraints

Configuring a Static EIP for a Pod

When creating a pod to be bound with a static IP address, configure the EIP annotation. Then, an EIP will be automatically allocated and bound to the pod.

The following uses a StatefulSet named nginx as an example. For details about annotations, see Table 1.

Table 1 Annotations of the pod's static EIP

Annotation

Mandatory

Default Value

Description

Value Range

yangtse.io/static-eip

Yes

false

Specifies whether to enable the static EIP of a pod. This function is supported only for StatefulSet pods or pods without ownerReferences. This function is disabled by default.

false or true

yangtse.io/static-eip-expire-duration

No

5m

Specifies the interval for reclaiming the expired static EIP after the pod with a static EIP is deleted.

The time format is Go time type, for example, 1h30m and 5m. For details, see Go time type.

yangtse.io/static-eip-expire-no-cascading

No

false

Specifies whether to disable cascading reclamation of StatefulSet workloads.

The default value is false, indicating that the corresponding static EIP will be deleted with the StatefulSet workload. If you want to retain the static EIP for a new StatefulSet with the same name during the interval for reclaiming the expired EIP, set the value to true.

false or true

Table 2 Annotations of an EIP with a dedicated bandwidth

Annotation

Mandatory

Default Value

Description

Value Range

yangtse.io/pod-with-eip

Yes

false

Whether to allocate an EIP with a pod and bind the EIP to the pod

false or true

yangtse.io/eip-bandwidth-size

No

5

Bandwidth, in Mbit/s

The value range varies depending on the region and bandwidth billing mode. For details, see the EIP console.

yangtse.io/eip-network-type

No

5_bgp

EIP type

The type varies depending on the region. For details, see on the EIP console.

yangtse.io/eip-charge-mode

No

None

Billed by traffic or bandwidth

You are advised to configure this parameter. If this parameter is left blank, no billing mode is specified. In this case, the default value of the EIP API in the region is used.

  • bandwidth: billed by bandwidth
  • traffic: billed by traffic

yangtse.io/eip-bandwidth-name

No

Pod name

Bandwidth name

  • Enter 1 to 64 characters. Only letters, digits, hyphens (-), underscores (_), and periods (.) are allowed.
  • Minimum length: 1 character
  • Maximum length: 64 characters
Table 3 Annotations of an EIP with a shared bandwidth

Annotation

Mandatory

Default Value

Description

Value Range

yangtse.io/pod-with-eip

Yes

false

Whether to allocate an EIP with a pod and bind the EIP to the pod

false or true

yangtse.io/eip-network-type

No

5_bgp

EIP type

  • 5_bgp

The specific type varies with regions. For details, see the EIP console.

yangtse.io/eip-bandwidth-id

Mandatory when a shared bandwidth is used

None

ID of an existing bandwidth

  • If this parameter is not specified, the EIP with a dedicated bandwidth is used by default. For details about how to configure parameters for an EIP with a dedicated bandwidth, see Table 1.
  • Only the yangtse.io/eip-network-type field can be specified concurrently, and this field is optional.

None

Deleting a Static EIP

After a pod is deleted, if another pod with the same name is created before the static EIP expires, the EIP can still be used. The static EIP is deleted only if there is no new pod with the name the same as that of the deleted pod before the EIP expires, or the function of deleting the EIP with the associated StatefulSet is enabled and the StatefulSet is deleted.