Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Cloud Container Instance/ Developer Guide/ EIP/ Binding a New EIP to a Pod

Binding a New EIP to a Pod

Updated on 2024-11-01 GMT+08:00

Allocating an EIP During Pod Creation

When creating a pod, configure pod-with-eip under annotations. An EIP is automatically assigned and bound to the pod.

The following uses a Deployment named nginx as an example. For details about the parameters, see Table 1.

  • To create a Deployment that uses a dedicated bandwidth, you do not need to specify the bandwidth ID.
    apiVersion: apps/v1
    kind: Deployment 
    metadata:   
      annotations:   
        deployment.kubernetes.io/revision: "14"   
        description: "" 
      name: nginx  
      namespace: eip 
    spec:
      ...   
      template: 
        metadata:   
          annotations:    
            yangtse.io/pod-with-eip: "true"  
            yangtse.io/eip-bandwidth-size: "5" 
            yangtse.io/eip-network-type: 5_g-vm
            yangtse.io/eip-charge-mode: bandwidth
            yangtse.io/eip-bandwidth-name: "xxx"
  • To create a Deployment that uses a shared bandwidth, you must and only need to specify the bandwidth ID.
    apiVersion: apps/v1
    kind: Deployment 
    metadata:   
      annotations:   
        deployment.kubernetes.io/revision: "14"   
        description: "" 
      name: nginx  
      namespace: eip 
    spec:
      ...   
      template:    
        metadata:   
          annotations:
            yangtse.io/pod-with-eip: "true"  
            yangtse.io/eip-bandwidth-id: "xxx"  
Table 1 Parameter description

Parameter

Description

Mandatory

Constraint

yangtse.io/pod-with-eip

The EIP allocated during pod creation

Yes

This option is enabled only when the parameter value is set to true.

yangtse.io/eip-bandwidth-size

The bandwidth that will be used by the EIP

No

The default value is 5.

yangtse.io/eip-network-type

The bandwidth type

No

The default value is 5_bgp. If your region does not support 5_bgp and this parameter is left empty, an event is reported for the pod.

yangtse.io/eip-charge-mode

Bandwidth billing option

No

The value can be bandwidth (default) or traffic.

yangtse.io/eip-bandwidth-id

ID of the shared bandwidth

Yes (for shared bandwidths)

If you have set this parameter, you do not need to set other values.

yangtse.io/eip-bandwidth-name

Bandwidth name

No

The default value is the same as the EIP name.

Verifying the EIP Allocation

The startup time of the pod may be earlier than the time when the EIP allocation result is returned. During pod startup, the EIP may fail to be bound.

You can use an init container to check whether the EIP is allocated. After the pod IP address is allocated, the container network controller binds an EIP to the pod and returns the allocation result to the annotation (yangtse.io/allocated-ipv4-eip) of the pod. You can configure an init container in the pod and use the downward API to mount the annotation to the init container through a volume to check whether the EIP is allocated. You can configure the init container as follows:

NOTICE:

CCI allows EIPs to be automatically bound to pods. EIPs are allocated after pod scheduling is complete. EIP annotations cannot be injected to pods through ENV.

apiVersion: v1
kind: Pod
metadata:
  name: example
  namespace: demo
  annotations:
    yangtse.io/pod-with-eip: "true"  
    yangtse.io/eip-bandwidth-size: "5" 
    yangtse.io/eip-network-type: 5_g-vm
    yangtse.io/eip-charge-mode: bandwidth
    yangtse.io/eip-bandwidth-name: "xxx"
spec:
  initContainers:
  - name: init
    image: busybox:latest
    command: ['timeout', '60', 'sh', '-c', "until grep -E '[0-9]+' /etc/eipinfo/allocated-ipv4-eip; do echo waiting for allocated-ipv4-eip; sleep 2; done"]
    volumeMounts:
        - name: eipinfo
          mountPath: /etc/eipinfo
  volumes:
    - name: eipinfo
      downwardAPI:
        items:
          - path: "allocated-ipv4-eip"
            fieldRef:
              fieldPath: metadata.annotations['yangtse.io/allocated-ipv4-eip']

Releasing an EIP During Pod Deletion

When you delete a pod, the EIP bound to it is also released. You can run the following command to delete a pod:

# kubectl delete pod nginx -n $namespace_name

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback