The default Kubernetes/OpenShift behavior is to round-robin load-balance across all available pods behind a single Service. Add another replica of recommendations-v2 Deployment.

oc scale --replicas=2 deployment/recommendation-v2

Wait the second recommendation:v2 pod to become available, execute oc get pods -w

Once that the recommendation pod READY column is 2/2, you can hit CTRL+C.

Make sure that the following command is running on Terminal 2while true; do curl http://customer-tutorial.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com; sleep .5; done

You will see two requests for v2 for each one of v1.

Scale back to a single replica of the recommendation-v2 deployment:

oc scale --replicas=1 deployment/recommendation-v2

On Terminal 2, you will see requests being round-robin balanced between v1 and v2.

All users to recommendation:v2

Open the file istiofiles/destination-rule-recommendation-v1-v2.yml.

Open the file istiofiles/virtual-service-recommendation-v2.yml.

Note that the DestinationRule adds a name to each version of our recommendation deployments, and VirtualService specifies that the destination will be the recommendation deployment with name version-v2.

Note: We used replace instead of create since we are overlaying the previous VirtualService.

Make sure that the following command is running on Terminal 2while true; do curl http://customer-tutorial.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com; sleep .2; done

you should only see v1 being returned.

Explore the VirtualService object

You can check the existing route rules by typing istioctl get virtualservice. It will show that we only have a VirtualService object called recommendations. The name has been specified in the VirtualService metadata.

You can check the contents of this VirtualService by executing istioctl get virtualservice recommendation -o yaml -n tutorial

All users to recommendation v1 and v2

We can now send requests to both v1 and v2 by simply removing the rule:

istioctl delete virtualservice recommendation -n tutorial

Make sure that the following command is running on Terminal 2while true; do curl http://customer-tutorial.[[HOST_SUBDOMAIN]]-80-[[KATACODA_HOST]].environments.katacoda.com; sleep .2; done

You should be able to see the default behavior of round-robin balancing between v1 and v2 being returned.

Canary deployment: Split traffic between v1 and v2

Think about the following scenario: Push v2 into the cluster but slowing send end-user traffic to it, if you continue to see success, continue shifting more traffic over time.

Let's now how we would create a VirtualService that sends 90% of requests to v1 and 10% to v2.

Take a look at the file /istiofiles/virtual-service-recommendation-v1_and_v2.yml

It specifies that recommendation with name version-v1 will have a weight of 90, and recommendation with name version-v2 will have a weight of 10.

Debugging Scenarios

Help

Katacoda offerings an Interactive Learning Environment for Developers. This course uses a command line and a pre-configured sandboxed environment for you to use. Below are useful commands when working with the environment.

cd <directory>

Change directory

ls

List directory

echo 'contents' > <file>

Write contents to a file

cat <file>

Output contents of file

Vim

In the case of certain exercises you will be required to edit files or text. The best approach is with Vim. Vim has two different modes, one for entering commands (Command Mode) and the other for entering text (Insert Mode). You need to switch between these two modes based on what you want to do. The basic commands are: