A small set of Apache Camel Microservice applications
A small set of Apache Camel Microservice applications, used for the basis of my London JBug presentation.
Demonstrates running two different flavours of Camel Microservice on Kubernetes and OpenShift:
The demo is composed of 3 Microservices. The overall aim is to generate a name that is made up of a title, first name and last name.
The client selects a random first name and HTTP POSTs this to the second service
The prefix service selects a random title and prepends this to the name sent from the client service. The modified name is then HTTP POSTed to the third service.
The suffix service selects a random last name and a random noun word. This is appended to the name received from the prefix service.
Minikube and Minishift was used as a simple means of running a local development cluster.
The example applications can be deployed to either a Kubernetes or OpenShift cluster. For simplicity, Minikube or Minishift are useful for running a local cluster.
Note: For brevity, kubectl is used as the cluster client command. If you're using OpenShift, substitue kubectl for oc.
To deploy OpenTracing and Hystrix servers run:
kubectl create -f deployment-kubernetes.yml
For OpenShift run:
oc create -f deployment-openshift.yml
Depending on the speed of your connection it may take a while for the images to be pulled. You can check progress by examining the pod status:
kubectl get pod
NAME READY STATUS RESTARTS AGE
hystrix-dashboard-4190263026-0tou6 1/1 Running 0 37s
turbine-server-56523232-eio5i 1/1 Running 0 37s
Once everything is up and running, we can connect to the Hystrix dashboard via its NodePort address:
kubectl get service
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hystrix-dashboard 10.0.0.90 <nodes> 80/TCP 1m
turbine-server 10.0.0.115 <nodes> 80/TCP 1m
kubectl describe service hystrix-dashboard
Name: hystrix-dashboard
Namespace: default
Type: NodePort
IP: 10.0.0.90
Port: <unset> 80/TCP
NodePort: <unset> 31137/TCP
Endpoints: 172.17.0.3:8080
In the above example you would browse to http://your-cluster-ip:31137 and the Hystrix Dashboard should be displayed. You can accept the default URL of http://turbine-server/turbine.stream and click the 'Monitor Stream' button.
Initially you'll be presented with nothing more than a 'Loading...' message, because there are no deployed applications emitting Hystrix events.
Once the OpenTracing pod is up and running you can access the web UI by using the method outlined above for finding the OpenTracing service NodePort.
For OpenShift you can use the route URL to access the services. You can view the service URLs by running:
oc get route opentracing hystrix-dashboard
If you're using Minikube or Minishift, it makes sense to use the Docker daemon of the VM rather than the one on your host:
eval $(minikube docker-env)
Otherwise the images built by the Maven build will need pushing to Docker Hub or another registry.
To build and deploy each application to the cluster do:
mvn fabric8:deploy
When each pod has successfully started you can change into the name-service-client
directory and tail the pod log:
cd name-service-client
mvn fabric8:log
You should start to see random names being output to the console every 10 seconds.
By default, names are generated every 10 seconds. To change this do:
kubectl edit configmap client-service-config
Then modify the timer.period
property. Saving the changes will reflect immediately in the running application.
For OpenShift you can deploy Prometheus using a template. Change the NAMESPACE
template parameter as necessary:
oc login -u system:admin
oc process -f etc/prometheus/prometheus-openshift.yml -p NAMESPACE=myproject | oc create -f -
Once everything is deployed you can access the Prometheus UI via its route URL:
oc get route prometheus
Prometheus is configured to search for services annotated with a label named group
with a value of com.github.jamesnetherton
. Thus it automatically finds and scrapes the metrics endpoints for services deployed in this demonstration.
The simplest way to run the project locally is with docker-compose.
Make sure you have built the project docker images locally by running:
mvn clean install
Then start the services:
docker compose up
You should see some humorous names being output to the console.
Some monitoring tools are available for you to view runtime metrics.
You can tear down all of the deployed project objects by:
mvn fabric8:undeploy