Kepler (Kubernetes-based Efficient Power Level Exporter) is a Prometheus exporter. It uses eBPF to probe CPU performance counters and Linux kernel tracepoints.
These data and stats from cgroup and sysfs can then be fed into ML models to estimate energy consumption by Pods.
- Set up
Kind
cluster.
kind create cluster --config=./01-setup-cluster/01-local-cluster-config.yml
- Update the context to use freshly created cluster. (kind does automatically switch context)
kubectl config use-context kind-kepler-demo-local-cluster
kubectl cluster-info --context kind-kepler-demo-local-cluster
- Setting up Prometheus and Grafana using
kube-prometheus-stack
.
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus prometheus-community/kube-prometheus-stack \
--namespace monitoring \
--create-namespace \
--wait
- Verify the resources.
kubectl --namespace monitoring get pods -l "release=prometheus"
#NAME READY STATUS RESTARTS AGE
#prometheus-kube-prometheus-operator-8484fbd69d-g7lvl 1/1 Running 0 4m3s
#prometheus-kube-state-metrics-6f659dc9cb-xjzx2 1/1 Running 0 4m3s
#prometheus-prometheus-node-exporter-g7mg2 1/1 Running 0 4m3s
- And, we have alert manager as well as grafana also running.
kubectl --namespace monitoring get pods
NAME READY STATUS RESTARTS AGE
alertmanager-prometheus-kube-prometheus-alertmanager-0 2/2 Running 0 14h
prometheus-grafana-6ffd599f89-wwrf5 3/3 Running 0 14h
prometheus-kube-prometheus-operator-8484fbd69d-g7lvl 1/1 Running 0 14h
prometheus-kube-state-metrics-6f659dc9cb-xjzx2 1/1 Running 0 14h
prometheus-prometheus-kube-prometheus-prometheus-0 2/2 Running 0 14h
prometheus-prometheus-node-exporter-g7mg2 1/1 Running 0 14h
- Doing port forward for grafana to access the dashboard.
It's easier to configure using k9s. Start the utility and type namespace
to list all namespaces and choose monitoring
.
Choose the pod with prometheus-grafana-*
and press shift-f
for port forwarding.
I have used port 3002
as the port 3000 in my machine is already occupied by different service.
- Access the grafana dashboard on url: Grafana local and use the credentials: username as
admin
and password asprom-operator
.
- Setting up kepler repo and installing latest version.
helm repo add kepler https://sustainable-computing-io.github.io/kepler-helm-chart
helm repo update
- Find the latest version of the kepler.
helm search repo kepler
- Make a dry run.
helm install kepler kepler/kepler --namespace kepler --create-namespace --dry-run --devel
- Deploy kepler
helm install kepler kepler/kepler \
--namespace kepler \
--create-namespace \
--set serviceMonitor.enabled=true \
--set serviceMonitor.labels.release=prometheus
- Verify the installation
KPLR_POD=$(
kubectl get pod \
-l app.kubernetes.io/name=kepler \
-o jsonpath="{.items[0].metadata.name}" \
-n kepler
)
kubectl wait --for=condition=Ready pod $KPLR_POD --timeout=-1s -n kepler
As there is no load and consumption, hence the load will almost equivalent to zero. Go to Dashboard
and click on new
and choose Import
. With import option, we can add predefined JSON
files from the kepler github repo. The json files also present in folder 03-grafana-dashboard.
And, then simply upload the JSON files, and access it.
With help of the dashboard you can monitor the resources, and can optimize the usage.
- List all the deployments.
$ helm list --all-namespaces | awk '{print $1, $2}'
NAME NAMESPACE
kepler kepler
prometheus monitoring
- Uninstall the deployment.
$ helm uninstall kepler --namespace kepler
release "kepler" uninstalled
$ helm uninstall prometheus --namespace monitoring
release "prometheus" uninstalled
Thank you for contributing towards the green development 🌍.