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

Ingress

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

The previous section describes how to create a LoadBalancer Service that uses a load balancer to access pods.

Services forward requests using TCP and UDP at Layer 4. Ingresses can forward requests using HTTP and HTTPS at Layer 7. Domain names and paths can be used for finer granularities.

Figure 1 Ingress-Service

In CCI, external access is implemented by binding the load balancer's IP address and port number to an ingress, as shown in Figure 2.

Figure 2 Ingress

Load Balancers

Ingresses can be bound to load balancers. You can create a load balancer by using the API or the ELB console.

A load balancer can work on a private network or public network. If the load balancer has a public IP address, it can route requests over the public network.

Creating an Ingress

  • Creating an HTTP ingress
    In the following example, the associated backend is nginx:8080. When http://10.10.10.10:6071/ is accessed, the traffic is forwarded to the Service corresponding to nginx:8080, and then to the corresponding pod.
    apiVersion: extensions/v1beta1                                   # Ingress version
    kind: Ingress
    metadata:
      name: nginx
      labels:
        app: nginx
        isExternal: "true"   # This parameter is mandatory and is reserved. The value must be true.
        zone: data         # Data plane mode. This parameter is reserved. The value must be data.
      annotations:
        kubernetes.io/elb.id: 2d48d034-6046-48db-8bb2-53c67e8148b5   # ID of the load balancer. This parameter is mandatory.
        kubernetes.io/elb.ip: 192.168.137.182                        # IP address of the load balancer. This parameter is optional.
        kubernetes.io/elb.port: '6071'                               # Port configured for the load balancer. This parameter is mandatory.
    spec:
      rules:                                                         # Routing rules
      - http:                                                        # Using HTTP protocol
          paths:
          - path: /                                                  # Route
            backend:
              serviceName: nginx                                     # Name of the Service to which requests are forwarded
              servicePort: 8080                                      # Port of the Service to which requests are forwarded

    You can also set the external domain name in an ingress so that you can access the load balancer through the domain name and then access backend Services.

    NOTE:

    Domain name-based access depends on domain name resolution. You need to point the domain name to the IP address of the load balancer. For example, you can use Domain Name Service (DNS) to resolve domain names.

    spec:
      rules:
      - host: www.example.com       # Domain name
        http:
          paths:
          - path: /
            backend:
              serviceName: nginx
              servicePort: 80
  • Creating an HTTPS ingress
    In the following example, the associated backend is nginx:8080. When https://10.10.10.10:6071/ is accessed, the traffic is forwarded to the Service corresponding to nginx:8080, and then to the corresponding pod.
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      annotations:
        kubernetes.io/elb.id: 2d48d034-6046-48db-8bb2-53c67e8148b5
        kubernetes.io/elb.ip: 192.168.137.182
        kubernetes.io/elb.port: '6071'
      labels:
        app: nginx
        isExternal: 'true'
        zone: data
      name: nginx
    spec:
      rules:
      - http:
          paths:
          - backend:
              serviceName: nginx
              servicePort: 8080
            path: /
      tls:
     - secretName: cci-sslcertificate-20214221                                 # Name of the uploaded SSL certificate

Accessing Multiple Services

An ingress can access multiple Services at the same time. The configuration is as follows:

  • When accessing http://foo.bar.com/foo, you access the backend s1:80.
  • When accessing http://foo.bar.com/bar, you access the backend s2:80.
spec:
  rules:
  - host: foo.bar.com          # Host address
    http:
      paths:
      - path: "/foo"
        backend:
          serviceName: s1
          servicePort: 80
      - path: "/bar"
        backend:
          serviceName: s2
          servicePort: 80

Configuring the Routing Service for URL Redirection

In the following example template, an ingress is connected to a backend service named service-test, and access requests to the /service-test path of the ingress will be redirected to the / path of service-test.
cat <<-EOF | kubectl apply -f -
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress-redirect-test
  namespace: default
 spec:
  rules:
  - host: ingress-test.com
    http:
      paths:
      - path: /
        backend:
          serviceName: service-test
          servicePort: 80
EOF

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