README.adoc 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. = Linux Metrics Exporter for OpenShift Nodes =
  2. == Components ==
  3. . Container Image for SAR
  4. . Container Image for PSACCT
  5. . Container Image for Exporter
  6. == How It All Works ==
  7. Very simple: two sidecar containers, `collector-sysstat` and
  8. `collector-psacct`, produce data on a shared ephemeral volume, and the third
  9. container, `metrics-exporter`, consumes the data and exposes it on the
  10. `/q/metrics` endpoint where Prometheus can pick them up.
  11. The specific thing about how the entire composition works is that care has been
  12. taken, especially with `psacct` (which can grow excessively during periods of
  13. high activity), that accounting files are regularly truncated or moved out of
  14. the way in order to keep the disk space utilisation as low as possible.
  15. == OpenShift Deployment ==
  16. TBD
  17. == Standalone ==
  18. Start the composition.
  19. // TODO: podman pod
  20. [subs+=quotes]
  21. ------
  22. $ *podman volume create metrics*
  23. metrics
  24. $ *podman run -d --rm -v metrics:/var/account --cap-add SYS_PACCT --pid=host collector-psacct:latest*
  25. dd9f4825d23614df2acefdcd70ec1e6c3ea18a58b86c9d17ddc4f91038487919
  26. $ *podman run -d --rm -v metrics:/var/log/sa collector-sysstat*
  27. ec3d0957525cc907023956a185b15123c20947460a48d37196d511ae42de2e27
  28. $ *podman run --name exporter -d --rm -v metrics:/metrics -p 8080:8080 metrics-exporter*
  29. d4840ad57bfffd4b069e7c2357721ff7aaa6b6ee77f90ad4866a76a1ceb6adb7
  30. ------
  31. Add prometheus and grafana.
  32. [subs+=quotes]
  33. ------
  34. $ *podman run --name prometheus \*
  35. *-d --rm \*
  36. *-v ./test/prometheus.yml:/etc/prometheus/prometheus.yml*
  37. *-v prometheus:/prometheus \*
  38. *-p 9090:9090 \*
  39. *registry.redhat.io/openshift4/ose-prometheus:v4.11*
  40. 6eae04677fcded65bbe1cb7f66aa887d94587977a0616f7ec838f9453702474c
  41. $ *podman run --name grafana -d --rm -p 3000:3000 \*
  42. *-v ./test/grafana.ini:/etc/grafana/grafana.ini \*
  43. *registry.redhat.io/openshift4/ose-grafana:v4.11*
  44. 78d5bfa7977923b828c1818bb877fa87bdd96086cc8c875fbc46073489f6760e
  45. ------
  46. == Images ==
  47. This set of images requires a valid entitlement for RHEL (and consequently
  48. either a RHEL system to build on or a RHEL system to create an entitlement
  49. secret from).
  50. IMPORTANT: You do not have to build the images, they are already provided by the `is-readymade.yml` resource.
  51. === SAR ===
  52. The _system activity reporting_ image is based on `ubi-minimal` and includes just the `sysstat` package.
  53. It expects a volume to be attached at `/var/log/sa`.
  54. Entrypoint takes care of initialising the `saXX` files.
  55. // TODO: and rotating any old files out of the way.
  56. It *requires* to be executed under `root` UID (can be rootless, but that may affect your data depending on host and container configuration).
  57. It also *requires* access to host's network namespace if you want to measure global network statistics.
  58. // NOTE: When running in a pod, the below is irrelevant as the exporter sets
  59. // the hostname, and you can override it there. It does however obtain
  60. // the default hostname from data sources.
  61. //
  62. // If aggregating from several hosts, you also need to use the hosts' UTS
  63. // namespace to report correct hostnames, or set the corresponding environment
  64. // variables to override detection.
  65. ==== Parameters ====
  66. TBD
  67. === PSACCT ===
  68. The _process accounting_ image is based on `ubi-minimal` and includes just the `psacct` package.
  69. It expects a volume to be attached at `/var/account`.
  70. Entrypoint takes care of rotating any old `pacct` files out of the way.
  71. In addition to *requiring* execution under a *real* `root` UID (i.e. *NOT* a rootless container), it also *requires* the `CAP_SYS_PACCT` capability (`--cap-add=SYS_PACCT`) and access to host's PID namespace (`--pid=host`).
  72. // NOTE: When running in a pod, the below is irrelevant as the exporter sets
  73. // the hostname, and you can override it there. It does however obtain
  74. // the default hostname from data sources.
  75. //
  76. // If aggregating from several hosts, you also need to use the hosts' UTS
  77. // namespace to report correct hostnames, or set the corresponding environment
  78. // variables to override detection.
  79. ==== Parameters ====
  80. TBD
  81. === Exporter ===
  82. TBD
  83. // TODO: Add support for hostname overrides in app.
  84. // run a maven registry.access.redhat.com/ubi9/openjdk-17 container:
  85. //
  86. // podman volume create maven
  87. //
  88. // podman run -it \
  89. // --name exporter \
  90. // -v maven:/home/default/.m2/repository \
  91. // -v metrics:/metrics \
  92. // -v /Users/johndoe/Documents/workspaces/projects/p0f/linux-metrics-exporter/exporter:/exporter \
  93. // -p 8080:8080 \
  94. // registry.access.redhat.com/ubi9/openjdk-17 bash
  95. //
  96. // $ cd /exporter
  97. // $ mvn quarkus:dev
  98. ==== Parameters ====
  99. TBD
  100. === Building with Podman ===
  101. If building the images using `podman` on an entitled host, no extra steps need
  102. to be performed as host entitlements will automatically be imported into the
  103. build container.
  104. NOTE: When building for an architecture without the `ubi-minimal` image or on a
  105. host that can not be entitled (f.e. Fedora CoreOS), you can choose a different
  106. base image by using the `--from` option in `podman build`.
  107. [subs=+quotes]
  108. -------------------------------
  109. $ *podman build --from=registry.fedoraproject.org/fedora-minimal:36 -f ./images/Containerfile-sysstat -t collector-sysstat:latest*
  110. -------------------------------
  111. === Building in OpenShift ===
  112. If building the images in OpenShift Container Platform, you must make sure an
  113. entitlement secret and corresponding RHSM certificate secret are mounted inside
  114. the build pod in order for packages to be found and installed.
  115. NOTE: The entitled system architecture needs to match the container host!
  116. The process is as follows.
  117. .Verify access to host entitlement data.
  118. [subs=+quotes]
  119. -------------------------------
  120. $ **ls -l /etc/pki/entitlement/*.pem /etc/rhsm/ca/*.pem**
  121. -rw-r--r--. 1 root root 3272 Oct 31 06:09 /etc/pki/entitlement/_6028779042203586857_-key.pem
  122. -rw-r--r--. 1 root root 149007 Oct 31 06:09 /etc/pki/entitlement/_6028779042203586857_.pem
  123. -rw-r--r--. 1 root root 2305 Sep 2 2021 /etc/rhsm/ca/redhat-entitlement-authority.pem
  124. -rw-r--r--. 1 root root 7411 Sep 2 2021 /etc/rhsm/ca/redhat-uep.pem
  125. -------------------------------
  126. .Create corresponding secrets.
  127. [subs=+quotes]
  128. -------------------------------
  129. $ *oc create secret generic etc-pki-entitlement \*
  130. *--from-file=/etc/pki/entitlement/_6028779042203586857_-key.pem \*
  131. *--from-file=/etc/pki/entitlement/_6028779042203586857_.pem*
  132. secret/etc-pki-entitlement created
  133. $ *oc create secret generic rhsm-ca \*
  134. *--from-file=/etc/rhsm/ca/redhat-entitlement-authority.pem \*
  135. *--from-file=/etc/rhsm/ca/redhat-uep.pem*
  136. secret/rhsm-ca created
  137. -------------------------------
  138. .Make sure the BuildConfig mounts those secrets.
  139. [subs=+quotes]
  140. -------------------------------
  141. apiVersion: build.openshift.io/v1
  142. kind: BuildConfig
  143. ...
  144. strategy:
  145. type: Docker
  146. dockerStrategy:
  147. dockerfilePath: Containerfile-psacct
  148. from:
  149. kind: ImageStreamTag
  150. name: ubi-minimal:latest
  151. **volumes:
  152. - source:
  153. type: Secret
  154. secret:
  155. secretName: etc-pki-entitlement
  156. name: etc-pki-entitlement
  157. mounts:
  158. - destinationPath: /etc/pki/entitlement
  159. - source:
  160. type: Secret
  161. secret:
  162. secretName: rhsm-ca
  163. name: rhsm-ca
  164. mounts:
  165. - destinationPath: /etc/rhsm/ca**
  166. -------------------------------
  167. `Containerfile` instructions are written such that they should work without
  168. modification regardless of whether the build is running in `podman` on an
  169. entitled host or inside a correctly configured OpenShift builder pod.
  170. NOTE: Key thing in `Containerfile` steps is to remove `/etc/rhsm-host` at some
  171. point unless `/etc/pki/entitlement-host` contains something (such as for
  172. example, valid entitlemets). Both are symlinks to `/run/secrets`.