github.com/nginxinc/kubernetes-ingress@v1.12.5/examples-of-custom-resources/traffic-splitting/README.md (about)

     1  # Traffic Splitting 
     2  
     3  In this example we use the [VirtualServer](https://docs.nginx.com/nginx-ingress-controller/configuration/virtualserver-and-virtualserverroute-resources/) resource to configure traffic splitting for the cafe application from the [Basic Configuration](../basic-configuration/) example, for which we have introduced the following changes:
     4  * Instead of one version of the coffee service, we have two: `coffee-v1-svc` and `coffee-v2-svc`. We send 90% of the coffee traffic to `coffee-v1-svc` and the remaining 10% to `coffee-v2-svc`.
     5  * To simplify the example, we have removed TLS termination and the tea service.
     6  
     7  ## Prerequisites  
     8  
     9  1. Follow the [installation](https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/) instructions to deploy the Ingress Controller with custom resources enabled.
    10  1. Save the public IP address of the Ingress Controller into a shell variable:
    11      ```
    12      $ IC_IP=XXX.YYY.ZZZ.III
    13      ```
    14  1. Save the HTTP port of the Ingress Controller into a shell variable:
    15      ```
    16      $ IC_HTTP_PORT=<port number>
    17      ```
    18  
    19  ## Step 1 - Deploy the Cafe Application
    20  
    21  Create the coffee deployments and services:
    22  ```
    23  $ kubectl create -f cafe.yaml
    24  ```
    25  
    26  ## Step 2 - Configure Load Balancing
    27  
    28  Create the VirtualServer resource:
    29  ```
    30  $ kubectl create -f cafe-virtual-server.yaml
    31  ```
    32  
    33  ## Step 3 - Test the Configuration
    34  
    35  1. Check that the configuration has been successfully applied by inspecting the events of the VirtualServer:
    36      ```
    37      $ kubectl describe virtualserver cafe
    38      . . .
    39      Events:
    40        Type    Reason          Age   From                      Message
    41        ----    ------          ----  ----                      -------
    42        Normal  AddedOrUpdated  5s    nginx-ingress-controller  Configuration for default/cafe was added or updated
    43      ```
    44  1. Access the application using curl. We'll use curl's `--resolve` option to set the IP address and HTTP port of the Ingress Controller to the domain name of the cafe application. Try to get coffee multiple times to see how NGINX sends requests to different versions of the coffee service:
    45      ```
    46       $ curl --resolve cafe.example.com:$IC_HTTP_PORT:$IC_IP http://cafe.example.com:$IC_HTTP_PORT/coffee
    47      ```
    48  
    49      90% of responses will come from `coffee-v1-svc`:
    50      ```
    51      Server address: 10.16.0.151:80
    52      Server name: coffee-v1-78754bdcfb-7xp27
    53      ...
    54      ```
    55  
    56      10 % of responses will come from `coffee-v2-svc`:
    57      ```
    58      Server address: 10.16.0.152:80
    59      Server name: coffee-v2-7fd446968b-lwhgcd
    60      ...