This assumes MicroShift is installed on a RHEL based machine. SSH into the virtual machine.
sudo systemctl enable --now microshift
mkdir ~/.kube
sudo cp /var/lib/microshift/resources/kubeadmin/kubeconfig ~/.kube/config
sudo chown -R $UID:$UID ~/.kube
oc get pods -A # all pods should soon be running
Kepler is a research project that that uses eBPF to probe CPU performance counters and Linux kernel tracepoints to calculate an application's carbon footprint. Refer to Kepler documentation for further information.
Note For running in MicroShift on Red Hat Device Edge, I've found it's easiest to use
kustomize
to apply kepler manifests, and a standalone OpenTelemetry Collector either with podman or as a sidecar container in the kepler-exporter DaemonSet. On other systems where resource constraints are less of a concern,helm
andopentelemetry operator
offer convenience.
git clone https://github.com/sustainable-computing-io/kepler.git
cd kepler
Uncomment the OpenShift lines in manifests/config/exporter/kustomization.yaml
(Line#3
and Line#16
at time of this writing),
and remove the []
in the line - patchesStrategicMerge: []
. Then, apply
the kepler manifests.
oc create ns kepler
oc label ns kepler security.openshift.io/scc.podSecurityLabelSync=false
oc label ns kepler --overwrite pod-security.kubernetes.io/enforce=privileged
oc apply --kustomize $(pwd)/manifests/config/base -n kepler
# Check that kepler pod is up and running before proceeding
To secure traffic from external OpenTelemetry Collector (OTC) to OpenShift OTC,
you can use this script to create a CA and generate
signed certificates for both the server (OpenShift OTC) and client (edge/external OTC).
This script also creates the secret, mtls-certs
, in the observability namespace that
is mounted in OpenShift OTC deployment below.
The OpenTelemetry Collector can run as a sidecar container to the kepler exporter DaemonSet.
Metrics will be sent from kepler to an OpenTelemetry Collector pod running in OpenShift. From there,
a prometheusremotewrite
opentelemetry collector exporter will send metrics to a Prometheus pod,
and a Prometheus datasource in Grafana will be used to visualize the data.
Run the following to launch an OpenTelemetry Collector sidecar container in the kepler-exporter Daemonset. Download the opentelemetry config file and modify as necessary to configure receivers and exporters.
oc create secret generic -n kepler mtls-certs --from-file ~/certs/ca.crt --from-file ~/certs/server.crt --from-file ~/certs/server.key
curl -o otelconfig.yaml https://raw.githubusercontent.com/redhat-et/edge-ocp-observability/main/edge/sample-app/kepler/microshift/otelconfig.yaml
# the exporter must be configured to match the OTLP receiver running in OpenShift
# replace $APPS_DOMAIN
oc create -n kepler -f otelconfig.yaml
# patch daemonset to add a sidecar opentelemetry collector container
curl -o patch-sidecar-otel.yaml https://raw.githubusercontent.com/redhat-et/edge-ocp-observability/main/edge/sample-app/kepler/microshift/patch-sidecar-otel.yaml
oc patch daemonset kepler-exporter -n kepler --patch-file patch-sidecar-otel.yaml
Check that the kepler-exporter now includes an otc-container and that the collector is receiving and exporting metrics as expected. Finally, deploy grafana in OpenShift with a prometheus datasource to view the metrics.
View the kepler-exporter prometheus metrics in Grafana with the upstream kepler exporter dashboard
If there is already a Grafana instance with a Prometheus Datasource in OpenShift -n observability
, run this command to
create the GrafanaDashboard for Kepler:
oc apply -f edge-ocp-observability/edge/sample-app/kepler/kepler-dashboard.yaml
If Grafana is not running in OpenShift, To deploy Grafana with a Prometheus DataSource in OpenShift, follow OpenShift observability hub: Grafana Then, deploy the Kepler dashboard with the above command.
You should now be able to access Grafana with username: rhel
and password:rhel
from the grafana route.
- Navigate to Dashboards -> to find Kepler Exporter dashboard.
- Navigate to Explore -> to find the Prometheus data source to query metrics from.
Hopefully, you'll see something like this!