Inject Failure Using Aborts¶
Let's inject the fault for certain percentage of the traffic. We will send a fixed response with HTTP code 503
.
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 abort failure with HTTP status code 503 for 80% 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 you receive 503
error for some of the requests.
Step 2: Generate Load and Verify Failure Percentage in Kiali¶
Let's use a script to automate traffic generation and record the failure rate:
Now, let's execute the script to generate traffic:
# Give execute permission to script
chmod +x generate-traffic.sh
# Execute script
./generate-traffic.sh
Wait for about 5 minutes and then view error rate in kiali. You'll notice that about 80% of the traffic fails with 503
HTTP error code.
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: