Skip to content

API Endpoints

Below, we demonstrate calling endpoints on the application in either of two ways:

  1. Internally from within the Kubernetes cluster
  2. Through the "front door", via the ingress gateway

    The environment variable LB_IP captures the public IP address of the load balancer fronting the ingress gateway. We can access the service endpoints through that IP address.

Deploy the sleep client

We make use of Istio's sleep sample application to facilitate the task of making calls to workloads from inside the cluster.

The sleep deployment is a blank client Pod that can be used to send direct calls to specific microservices from within the Kubernetes cluster.

Deploy sleep to your cluster:

kubectl apply -f istio-1.23.0/samples/sleep/sleep.yaml

Wait for the sleep pod to be ready (2/2 containers).

Test individual service endpoints

We assume that you have the excellent jq utility already installed.

Call the "Vets" controller endpoint

kubectl exec deploy/sleep -- curl -s vets-service:8080/vets | jq
curl -s http://$LB_IP/api/vet/vets | jq

Customers service endpoints

Here are a couple of customers-service endpoints to test:

kubectl exec deploy/sleep -- curl -s customers-service:8080/owners | jq
kubectl exec deploy/sleep -- curl -s customers-service:8080/owners/1/pets/1 | jq
curl -s http://$LB_IP/api/customer/owners | jq
curl -s http://$LB_IP/api/customer/owners/1/pets/1 | jq

Give the owner George Franklin a new pet, Sir Hiss (a snake):

kubectl exec deploy/sleep -- curl -s -v \
  -X POST -H 'Content-Type: application/json' \
  customers-service:8080/owners/1/pets \
  -d '{ "name": "Sir Hiss", "typeId": 4, "birthDate": "2020-01-01" }'
curl -v -X POST -H 'Content-Type: application/json' \
  http://$LB_IP/api/customer/owners/1/pets \
  -d '{ "name": "Sir Hiss", "typeId": 4, "birthDate": "2020-01-01" }'

This can also be performed directly from the UI.

The Visits service

Test one of the visits-service endpoints:

kubectl exec deploy/sleep -- curl -s visits-service:8080/pets/visits?petId=8 | jq
curl -s http://$LB_IP/api/visit/pets/visits?petId=8 | jq

PetClinic Frontend

Call petclinic-frontend endpoint that calls both the customers and visits services:

kubectl exec deploy/sleep -- curl -s petclinic-frontend:8080/api/gateway/owners/6 | jq
curl -s http://$LB_IP/api/gateway/owners/6 | jq

Summary

Now that we have some familiarity with some of the API endpoints that make up this application, let's turn our attention to configuring a small aspect of resilience: timeouts.