Inject Failure Using Delays¶
Let's inject failure using delays for 100% of the traffic.
Step 1: Deploy Application¶
First, let's deploy the application and other Istio components:
Make sure to replace the value of external-dns.alpha.kubernetes.io/target
annotation in virtual service with the istio load balancer DNS.
Observe that we are injecting a delay of 5 seconds for 100% of the traffic.
Assuming your folder structure looks like the one below:
|-- manifests
│ |-- 00-namespace.yml
│ |-- nginx-deployment.yml
│ |-- nginx-service.yml
│ |-- gateway.yml
│ |-- virtual-service.yml
Let's apply the manifests to create the kubernetes and istio objects:
Verify if the istio proxies are created for the application:
# Retrieve proxy configuration
istioctl proxy-config routes svc/istio-ingressgateway -n istio-system
Open the application in any browser and see if there is actually a delay in the response. Now, failure depends on the application, i.e., the application can set a timeout for the response and send a failure response if timed out.
In our case, we have not implemented a timeout in our application, so you would only notice the delay and not the actual failure due to a timeout.
Step 2: Generate Load and Verify Delay in Response¶
Let's use a script to automate traffic generation and record the delay:
Now, let's execute the script to generate traffic:
# Give execute permission to script
chmod +x generate-traffic.sh
# Execute script
./generate-traffic.sh
Observe the response time of each requests.
Note
You won't see the delay in Kiali because Kiali displays latency, not delay. Latency refers to the time from when a request reaches the server until the response is returned, whereas delay is the time from when a request is initiated to when the response is served.
Clean Up¶
Assuming your folder structure looks like the one below:
|-- manifests
│ |-- 00-namespace.yml
│ |-- nginx-deployment.yml
│ |-- nginx-service.yml
│ |-- gateway.yml
│ |-- virtual-service.yml
Let's delete all the kubernetes and istio resources we created: