Apply a policy
Use a fault injection policy to inject a delay to the reviews app. A delay simulates an overloaded upstream service or network issues, and can help you build more resilient apps. Then, you can check out the policy and other Gloo resources in the Gloo UI.
Apply fault injection
-
Verify that you can successfully send requests to the reviews app.
curl -vik --resolve www.example.com:80:$INGRESS_GW_IP http://www.example.com:80/reviews/1
Example output:
* Trying 34.86.142.191:80... * Connected to 34.86.142.191 (34.86.142.191) port 80 (#0) > GET /reviews/1 HTTP/1.1 > Host: 34.86.142.191 > User-Agent: curl/7.79.1 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK HTTP/1.1 200 OK ... < * Connection #0 to host 34.86.142.191 left intact {"id": "1","podname": "reviews-v1-55b668fc65-kwvq5","clustername": "null","reviews": [{ "reviewer": "Reviewer1", "text": "An extremely entertaining play by Shakespeare. The slapstick humour is refreshing!"},{ "reviewer": "Reviewer2", "text": "Absolutely fun and entertaining. The play lacks thematic depth when compared to other plays by Shakespeare."}]}%
-
Create a fault injection policy to delay responses from the reviews app by 10 seconds.
kubectl apply -f- <<EOF apiVersion: resilience.policy.gloo.solo.io/v2 kind: FaultInjectionPolicy metadata: name: faultinjection-basic-delay namespace: bookinfo spec: applyToRoutes: - route: labels: route: reviews config: delay: fixedDelay: 10s EOF
-
Send another request to the reviews app. Note that this time, the app's response is delayed due to the fault injection.
curl -vik --resolve www.example.com:80:$INGRESS_GW_IP http://www.example.com:80/reviews/1
Congratulations! You successfully created an API Gateway that routes incoming traffic to an upstream service and enforces network policies.
Launch the Gloo UI
The Gloo UI provides a single pane of glass through which you can observe the status of your service meshes, workloads, and services that run across all of your clusters. You can also view the policies that configure the behavior of your network.
-
Access the Gloo UI.
meshctl dashboard
-
Review the Dashboard page, which presents an at-a-glance look at the health of workspaces and clusters that make up your Gloo setup.
- In the Workspaces pane, you can review the workspace that was automatically created for you in your Gloo setup.
- In the Clusters pane, you can review the workload clusters that are currently connected to your Gloo setup.
-
Verify the details of the fault injection policy that you created in the previous section.
- Click the Resources tab to open the Solo resources page.
- In the row for your policy,
faultinjection-basic-delay
, click View Policy. - Review the details of the policy, such as the
reviews
route that it applies to. - Click View YAML.
- Scroll to the end of the YAML output to verify that the policy has a
state
ofACCEPTED
.
To learn more about what you can do with the UI, see the Gloo UI guides.
Next
Now that your API Gateway is up and running, you can do the following:
- Review other routing examples, such as header matching, redirects, or direct responses that you can configure for your API Gateway.
- Explore other policies that you can apply to your routes and upstream services. For example, you might apply the proxy protocol policy to your API Gateway so that it preserves connection information such as the originating client IP address.
- Learn more about Gloo Gateway and its features in Concepts.
- You can also check out some of the following resources to learn more about Gloo Gateway or try other Gloo Gateway features.
- Talk to an expert to get advice or build out a proof of concept.
- Join the #gloo-mesh channel in the Solo.io community slack.
- Try out one of the Gloo Platform workshops.
Cleanup
You can optionally remove the resources that you set up as part of this guide.-
Delete the fault injection policy.
kubectl delete FaultInjectionPolicy faultinjection-basic-delay -n bookinfo
-
If you no longer need this quick-start Gloo Gateway environment, you can uninstall gateway resources, sample apps, and Gloo management and agent components by following the steps in Uninstall Gloo Gateway.