Configuring a Static EIP for a Pod
Scenario
In CCE Autopilot clusters, static public IP addresses (EIPs) can be assigned to StatefulSets or pods that are created directly.
Constraints
- The static EIP function must be enabled together with the function of automatically allocating an EIP for a pod. For details, see Configuring an EIP for a Pod.
- Only StatefulSet pods or pods that are created directly can have static EIPs.
- After a static EIP is allocated, the EIP attributes cannot be modified through the pod within the EIP lifecycle (before the EIP expires or it is still being used by the pod).
- Do not configure a static EIP for services that do not have specific requirements on pod EIPs. Otherwise, the pod rebuilding takes a longer time.
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.
- For an automatically allocated EIP with a dedicated bandwidth when you create a StatefulSet, you do not need to specify the bandwidth ID. The following shows an example:
apiVersion: apps/v1 kind: StatefulSet metadata: name: nginx spec: serviceName: nginx replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx annotations: yangtse.io/static-eip: 'true' # Static EIP bound to the pod yangtse.io/static-eip-expire-no-cascading: 'false' # Deleting the EIP with the associated workload yangtse.io/static-eip-expire-duration: 5m # Interval for reclaiming expired EIPs yangtse.io/pod-with-eip: 'true' # An EIP will be automatically allocated when the pod is created. yangtse.io/eip-bandwidth-size: '5' # EIP bandwidth yangtse.io/eip-network-type: 5_bgp # EIP type yangtse.io/eip-charge-mode: bandwidth # EIP billing mode spec: containers: - name: container-0 image: nginx:alpine resources: limits: cpu: 100m memory: 200Mi requests: cpu: 100m memory: 200Mi imagePullSecrets: - name: default-secret
- For an automatically allocated EIP with a shared bandwidth when you create a StatefulSet, you are required to specify the bandwidth ID. The following shows an example:
apiVersion: apps/v1 kind: StatefulSet metadata: name: nginx spec: serviceName: nginx replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx annotations: yangtse.io/static-eip: 'true' # Static EIP bound to the pod yangtse.io/pod-with-eip: 'true' # An EIP will be automatically allocated when the pod is created. yangtse.io/eip-network-type: 5_bgp # EIP type yangtse.io/eip-bandwidth-id: <eip_bandwidth_id> # Shared bandwidth ID of the EIP spec: containers: - name: container-0 image: nginx:alpine resources: limits: cpu: 100m memory: 200Mi requests: cpu: 100m memory: 200Mi imagePullSecrets: - name: default-secret
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 |
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 purchase page on the EIP console. For example, in the AP-Singapore region, if an EIP is billed by bandwidth, the bandwidth ranges from 1 Mbit/s to 2000 Mbit/s; if an EIP is billed by traffic, the bandwidth ranges from 1 Mbit/s to 300 Mbit/s. |
yangtse.io/eip-network-type |
No |
5_bgp |
EIP type |
The type varies depending on the region. For details, see the purchase page on the EIP console. For example, the following options are available in in the AP-Singapore region:
|
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. |
|
yangtse.io/eip-bandwidth-name |
No |
Pod name |
Bandwidth name |
|
Annotation |
Mandatory |
Default Value |
Description |
Value Range |
---|---|---|---|---|
yangtse.io/pod-with-eip |
Yes |
false |
Whether to bind an EIP to a pod |
false or true |
yangtse.io/eip-network-type |
No |
5_bgp |
EIP type |
|
yangtse.io/eip-bandwidth-id |
Mandatory when a shared bandwidth is used |
None |
ID of an existing bandwidth
|
- |
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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot