You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: foundational/HealthProbe/README.adoc
+10-17Lines changed: 10 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,19 +2,18 @@
2
2
3
3
For this example we need a Kubernetes installation as described in link:../../INSTALL.adoc[INSTALLATION.adoc].
4
4
5
-
For our example for this pattern we are reusing our https://github.com/k8spatterns/random-generator[random-generator] which also includes support for health checks.
5
+
Here we are reusing our https://github.com/k8spatterns/random-generator[random-generator] which also includes support for health checks.
6
6
7
-
To apply a Deployment with liveness and readiness check enables, use
7
+
To apply a Deployment with liveness and readiness check enabled, use
Copy file name to clipboardExpand all lines: structural/Adapter/README.adoc
+59Lines changed: 59 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,65 @@
2
2
3
3
IMPORTANT: The instructions have not been written/finished, but the resource file has been verified. Instructions will be added soon.
4
4
5
+
In this example we will see how we can expose a the metrics created by the random generator REST service in a Prometheus conformant format.
6
+
7
+
By intention the metrics created by the the random-generator service is written is an own format which can't be used by Prometheus directly.
8
+
Also the metrics are not exposed via a network port but is written into the filesystem.
9
+
We are using an _Adapter_ sidecar container to convert and expose data written in that custom proprietary format over HTTP so that it can be scraped by Prometheus.
10
+
11
+
Let's see how this works.
12
+
13
+
We are using a bare Pod for simplicities sake (in real world scenarios this would be of course e.g. a Deployment).
14
+
15
+
Please have a look into the `pod.yml` descriptor which
16
+
17
+
* Create two containers: One is our `random-generator` the other is the _Adapter_, `k8spatterns/random-generator-exporter`. This is a simple Perl script (yeah, Perl ;) which does the transformation. You find the Dockerfile and script for this image in the link::image/[image] directory.
18
+
* Create a volume which is shared between the main application container and the adapter. The main container writes the metrics file into this shared directory, and the Prometheus _Adapter_ picks it up when queried over HTTP
This Service uses a `nodePort` to expose it on every node of the cluster.
35
+
For Minikube this works nicely.
36
+
However, if your cluster nodes are not exposed, you might either use our `kubectl port-forward` hack used in other examples or use a full ingress or loadbalancer exposed route as described in the _Service Discovery_ pattern.
37
+
38
+
Let's assume that you are using Minikube for now, so that we can access the
39
+
Then let's access our Service with
40
+
41
+
[source, bash]
42
+
----
43
+
port=$(kubectl get svc random-generator -o jsonpath={.spec.ports[0].nodePort})
44
+
curl http://$(minikube ip):$port
45
+
----
46
+
47
+
When we now jump into the Pod we can examine the generated metrics file
48
+
49
+
[source, bash]
50
+
----
51
+
kubectl exec -it random-generator -c main bash
52
+
cat /logs/random.log
53
+
----
54
+
55
+
NOTE: You could also have entered the `adapter` container which mounts the same directory at `/logs/`, too
56
+
57
+
The metrics extracted from that data can now be accessed in a Prometheus conformant way:
58
+
59
+
[source, bash]
60
+
----
61
+
prom_port=$(kubectl get svc random-generator -o jsonpath={.spec.ports[1].nodePort})
0 commit comments