Pablo Solar VilariƱo
2020-06-19 49a69db8fa634d24fc03f35cb8589e87c260fa1f
commit | author | age
f92636 1 Customer
JS 2 ========
3
4 This is the customer microservice, part of the Istio Tutorial demo. Even though this microservice is meant to be executed within a Container on a Pod on Kubernetes/OpenShift, it can still be executed on bare metal.
5
6 This is a regular Wildfly Swarm application, with OpenTracing and Jaeger dependencies to provide distributed tracing capabilities.
7
8 Running on the local machine
9 ============================
10
11 To run this service for development purposes on your own machine, execute:
12
13 ```bash
14 JAEGER_SERVICE_NAME=customer mvn wildfly-swarm:run
15 ```
16
17 The environment variable `JAEGER_SERVICE_NAME` is required, as the Jaeger Tracer is embedded into our application and expects a service name to be specified. The example should work, however, even when an installation of Jaeger is *not* available.
18
19 If you do prefer to have a local Jaeger instance running to see the traces, the easiest is to start via a Docker
20 container:
21
22 ```bash
23 docker run \
24   --rm \
25   -p5775:5775/udp \
26   -p6831:6831/udp \
27   -p6832:6832/udp \
28   -p16686:16686 \
29   -p14268:14268 \
30   jaegertracing/all-in-one:1.3
31 ```
32
33 The default configuration for the Jaeger tracer samples only a small portion of the requests. To trace every incoming request and report the spans to the log file, export the following environment variables and start the application again:
34
35 ```bash
36 export JAEGER_REPORTER_LOG_SPANS=true
37 export JAEGER_SAMPLER_TYPE=const
38 export JAEGER_SAMPLER_PARAM=1
39 ```
40
41 To test, call http://localhost:8280/
42
43 ```
44 $ curl http://localhost:8280/
45 customer => preference => recommendation v1 from 'caju': 3
46 ```
47
48 ![Trace View](trace.png)
49
50 Running on OpenShift
51 ====================
52
53 The following commands will build a Docker image containing the application, create a Kubernetes `Deployment` and a corresponding `Service`, so that other services can discover the pods via the service name.
54
55 ```bash
56 mvn clean package
57 docker build -t example/customer .
58 docker images | grep customer
59 oc apply -f ../../kubernetes/Deployment.yml
60 oc apply -f ../../kubernetes/Service.yml
61 oc expose service customer
62 ```
63
64 The last command will expose the service to the outside world, allowing you to make an HTTP call directly from your host machine:
65
66 ```
67 curl http://customer-tutorial.127.0.0.1.nip.io/
68 ```