README.adoc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. `/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`, that accounting files are regularly moved out
  13. of the way in order to keep the disk space utilisation as low as possible.
  14. == Deployment ==
  15. TBD
  16. == Images ==
  17. This set of images requires a valid entitlement for RHEL (and consequently
  18. either a RHEL system to build on or a RHEL system to create an entitlement
  19. secret from).
  20. IMPORTANT: You do not have to build the images, they are already provided by the `is-readymade.yml` resource.
  21. === SAR ===
  22. The _system activity reporting_ image is based on `ubi-minimal` and includes just the `sysstat` package.
  23. It expects a volume to be attached at `/var/log/sa`.
  24. Entrypoint takes care of initialising the `saXX` files and rotating any old files out of the way.
  25. It *requires* to be executed under `root` UID (can be rootless, but that may affect your data depending on host and container configuration).
  26. It also *requires* access to host's network namespace if you want to measure global network statistics.
  27. === PSACCT ===
  28. The _process accounting_ image is based on `ubi-minimal` and includes just the `psacct` package.
  29. It expects a volume to be attached at `/var/account`.
  30. Entrypoint takes care of rotating any old `pacct` files out of the way.
  31. 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`).
  32. === Exporter ===
  33. TBD
  34. === Building with Podman ===
  35. If building the images using `podman` on an entitled host, no extra steps need
  36. to be performed as host entitlements will automatically be imported into the
  37. build container.
  38. ******
  39. NOTE: When building for an architecture without the `ubi-minimal` image or on a
  40. host that can not be entitled (f.e. Fedora CoreOS), you can choose a
  41. different base image by using the `--from` option in `podman build`:
  42. [subs=+quotes]
  43. -------------------------------
  44. $ *podman build --from=registry.fedoraproject.org/fedora-minimal:36 -f ./images/Containerfile-sysstat -t collector-sysstat:latest*
  45. -------------------------------
  46. ******
  47. === Building in OpenShift ===
  48. If building the images in OpenShift Container Platform, you must make sure an
  49. entitlement secret and corresponding RHSM certificate secret are mounted inside
  50. the build pod in order for packages to be found and installed.
  51. NOTE: The entitled system architecture needs to match the container host!
  52. The process is as follows.
  53. .Verify access to host entitlement data.
  54. [subs=+quotes]
  55. -------------------------------
  56. $ **ls -l /etc/pki/entitlement/*.pem /etc/rhsm/ca/*.pem**
  57. -rw-r--r--. 1 root root 3272 Oct 31 06:09 /etc/pki/entitlement/_6028779042203586857_-key.pem
  58. -rw-r--r--. 1 root root 149007 Oct 31 06:09 /etc/pki/entitlement/_6028779042203586857_.pem
  59. -rw-r--r--. 1 root root 2305 Sep 2 2021 /etc/rhsm/ca/redhat-entitlement-authority.pem
  60. -rw-r--r--. 1 root root 7411 Sep 2 2021 /etc/rhsm/ca/redhat-uep.pem
  61. -------------------------------
  62. .Create corresponding secrets.
  63. [subs=+quotes]
  64. -------------------------------
  65. $ *oc create secret generic etc-pki-entitlement \*
  66. *--from-file=/etc/pki/entitlement/_6028779042203586857_-key.pem \*
  67. *--from-file=/etc/pki/entitlement/_6028779042203586857_.pem*
  68. secret/etc-pki-entitlement created
  69. $ *oc create secret generic rhsm-ca \*
  70. *--from-file=/etc/rhsm/ca/redhat-entitlement-authority.pem \*
  71. *--from-file=/etc/rhsm/ca/redhat-uep.pem*
  72. secret/rhsm-ca created
  73. -------------------------------
  74. .Make sure the BuildConfig mounts those secrets.
  75. [subs=+quotes]
  76. -------------------------------
  77. apiVersion: build.openshift.io/v1
  78. kind: BuildConfig
  79. ...
  80. strategy:
  81. type: Docker
  82. dockerStrategy:
  83. dockerfilePath: Containerfile-psacct
  84. from:
  85. kind: ImageStreamTag
  86. name: ubi-minimal:latest
  87. **volumes:
  88. - source:
  89. type: Secret
  90. secret:
  91. secretName: etc-pki-entitlement
  92. name: etc-pki-entitlement
  93. mounts:
  94. - destinationPath: /etc/pki/entitlement
  95. - source:
  96. type: Secret
  97. secret:
  98. secretName: rhsm-ca
  99. name: rhsm-ca
  100. mounts:
  101. - destinationPath: /etc/rhsm/ca**
  102. -------------------------------
  103. `Containerfile` instructions are written such that they should work without
  104. modification regardless of whether the build is running in `podman` on an
  105. entitled host or inside a correctly configured OpenShift builder pod.
  106. NOTE: Key thing in `Containerfile` steps is to remove `/etc/rhsm-host` at some
  107. point unless `/etc/pki/entitlement-host` contains something (such as for
  108. example, valid entitlemets). Both are symlinks to `/run/secrets`.