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

Configuring Application Traffic Mirroring for an Nginx Ingress

Updated on 2025-02-18 GMT+08:00

Nginx ingresses can mirror inter-cluster traffic by duplicating access requests and sending them to the image backend without using the values returned from the backend. This allows for system simulation tests and fault locating without affecting the original requests. This section describes how to use Nginx ingresses to mirror traffic between applications in different clusters.

Figure 1 Traffic mirroring

Preparations

Step 1: Creating a Workload and Exposing Services Through an Ingress

  1. Deploy an application in cluster 1 and test the connection.

    Copy the following data and save it into the nginx-deploy.yaml file:
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        version: v1
      name: nginx
      namespace: default
    spec:
      selector:
        matchLabels:
          app: nginx
          version: v1
      template:
        metadata:
          labels:
            app: nginx
            version: v1
        spec:
          containers:
            - name: container-1
              image: nginx:latest
              imagePullPolicy: IfNotPresent
          terminationGracePeriodSeconds: 30
          dnsPolicy: ClusterFirst
      replicas: 1
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: nginx
      labels:
        app: nginx
      namespace: default
    spec:
      selector:
        app: nginx
      externalTrafficPolicy: Cluster
      ports:
        - name: cce-service-0
          targetPort: 80
          port: 80
          protocol: TCP
      type: NodePort
    ---
    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: nginx
      namespace: default
    spec:
      rules:
        - host: example.com
          http:
            paths:
              - path: /
                backend:
                  service:
                    name: nginx
                    port:
                      number: 80
                property:
                  ingress.beta.kubernetes.io/url-match-mode: STARTS_WITH
                pathType: ImplementationSpecific
      ingressClassName: nginx

  2. Run the following command to create a workload for cluster 1:

    kubectl apply -f nginx-deploy.yaml

  3. Repeat the preceding command to create the same workload in cluster 2.

Step 2: Configuring Traffic Replication

NOTE:
  • As the destination of traffic, cluster 2 does not require any modifications. You only need to configure cluster 1.
  • After the access traffic of the application in cluster 1 is replicated to the application in cluster 2, the client only receives the request response from cluster 1, while discarding the response from cluster 2.

Configure traffic mirroring for cluster 1. For more details, see Nginx Ingress Mirror.

kubectl patch ingress nginx --type merge --patch '"metadata": {"annotations": {"nginx.ingress.kubernetes.io/mirror-target": "http://<cluster_2_ingress_ip_address>:80/", "nginx.ingress.kubernetes.io/mirror-host": "example.com"}}'

In the preceding configuration, <cluster_2_ingress_ip_address> is the public IP address of the ingress load balancer in cluster 2.

Verification

Run the following command to access the application domain name example.com of cluster 1:

curl http://<cluster_1_ingress_ip_address>:80/ -H "Host: example.com"

Check nginx-ingress controller logs in cluster 1.

kubectl logs -f <cceaddon-nginx-ingress-controller_pod_name> -n kube-system

In the preceding command, <cceaddon-nginx-ingress-controller_pod_name> is the pod name of nginx-ingress controller.

According to the logs, whenever the domain name for the ingress in cluster 1 is requested, the request is duplicated and sent to the corresponding service in cluster 2.

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