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
Situation Awareness
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

Accessing the Internet from a Pod

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

How to Implement

The method of accessing a public network address from a pod varies depending on the network model of the cluster. For details, see Table 1.

Table 1 Methods of accessing a public network address from a pod

Implementation

Tunnel Network

VPC Network

Cloud Native 2.0 Network

Binding an EIP to the node where the container resides

Supported

Supported

Not supported

Binding an EIP to the pod

Not supported

Not supported

Supported

NOTE:

Bind an EIP to the pod. For details, see Configuring a Static EIP for a Pod.

Accessing the Internet through a NAT gateway

Supported

Supported

Supported

The following uses a CCE Turbo cluster as an example to describe how to use a NAT gateway to access the Internet. The NAT gateway allows containers in a VPC to access the Internet through source network address translation (SNAT), which translates containers' private IP addresses to public IP addresses using the assigned EIP. This allows the containers to use the shared EIP to access the Internet. For details, see Figure 1. SNAT allows containers in a VPC to access the Internet directly, even without an EIP. However, they cannot receive traffic from the Internet. The NAT gateway provides efficient support for high-concurrency connections and enables public network access. It is well-suited for scenarios with a large volume of requests and connections.

Figure 1 How an SNAT rule works

Prerequisites

Procedure

To enable a pod to access the Internet, perform the following steps:

  1. Check the pod CIDR block.

    1. Log in to the management console.
    2. Click in the upper left corner and choose Containers > Cloud Container Engine.
    3. Click the cluster name to access the cluster console. In the navigation pane, choose Overview. In the Networking Configuration area, check the pod subnet.
      Figure 2 Pod subnet

  2. Check the access from the pod to the Internet. Log in to the target pod and run the following command on the CloudShell page:

    curl -I console-intl.huaweicloud.com

    If information similar to the following is displayed, the pod cannot access the Internet:

    curl: (7) Failed to connect to console-intl.huaweicloud.com port 80: Connection timed out

  3. Assign an EIP. For details, see Assigning an EIP.

    1. Click in the upper left corner of the console and select a region.
      NOTE:

      Set Region to the one where the target pod is located.

    2. Click in the upper left corner and choose Networking > Elastic IP.
    3. On the EIPs page, click Buy EIP.
    4. Configure parameters as prompted. For details, see Figure 3.
      Figure 3 Buying an EIP

  4. Buy a NAT gateway. For details, see Buy a Public NAT Gateway.

    1. Click in the upper left corner and choose Networking > NAT Gateway.
    2. On the displayed page, click Buy Public NAT Gateway.
    3. Configure parameters as prompted. Set VPC to the one used by the cluster and Subnet to the pod subnet. For details, see Figure 4. When using a CCE Turbo cluster, set Subnet to the one where the pod is located. When using a CCE standard cluster, set Subnet to the one where the node is located.
      Figure 4 Buying a NAT gateway

  5. Configure an SNAT rule and bind the EIP to the subnet. For details, see Add an SNAT Rule.

    1. On the page displayed, click the name of the NAT gateway for which you want to add the SNAT rule.
    2. On the SNAT Rules tab page, click Add SNAT Rule.
    3. Configure parameters as prompted. For details, see Figure 5.
      NOTE:

      SNAT rules take effect by CIDR block. When configuring CIDR blocks for different container network models, consider their communication modes. Follow these rules to ensure proper configuration:

      • For a CCE standard cluster using a tunnel or VPC network, select the CIDR block where the node is located, which is the block selected during node creation.
      • For a CCE Turbo cluster using Cloud Native Network 2.0, select the container CIDR block used during cluster creation.

      If there are multiple CIDR blocks, you can create multiple SNAT rules or customize a CIDR block. Make sure that the selected CIDR block includes either the container subnet (for Cloud Native Network 2.0) or the node subnet (for tunnel network and VPC network).

      Figure 5 Adding an SNAT rule

  6. Check whether the pod can access the Internet. Log in to the target pod and run the following command on the CloudShell page:

    curl -I console-intl.huaweicloud.com

    If information similar to the following is displayed, the pod can access the Internet:

    HTTP/1.1 301 Moved Permanently
    Server: CloudWAF
    Date: Mon, 19 Aug 2024 12:43:20 GMT
    Content-Type: text/html
    Connection: keep-alive
    Set-Cookie: HWWAFSESID=b4119798a9b29b3c77; path=/
    Set-Cookie: HWWAFSESTIME=1724071396374; path=/
    ...

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