From 2e795652e5e2179c5b345fd64c445dce53d71571 Mon Sep 17 00:00:00 2001 From: Parul Singh Date: Thu, 29 Jun 2023 06:43:55 -0400 Subject: [PATCH] Merge following kepler ds changes into the operator: - https://github.com/sustainable-computing-io/kepler/pull/578 - https://github.com/sustainable-computing-io/kepler/pull/683 - https://github.com/sustainable-computing-io/kepler/pull/635 - https://github.com/sustainable-computing-io/kepler/pull/733 Signed-off-by: Parul Singh --- controllers/kepler_controller.go | 13 ++++++++++++- controllers/sahandler.go | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/controllers/kepler_controller.go b/controllers/kepler_controller.go index 265af394..248ec759 100644 --- a/controllers/kepler_controller.go +++ b/controllers/kepler_controller.go @@ -318,6 +318,8 @@ func (r *collectorReconciler) ensureConfigMap(l klog.Logger) (bool, error) { data_map["CGROUP_METRICS"] = "*" data_map["MODEL_CONFIG"] = "| CONTAINER_COMPONENTS_ESTIMATOR=false CONTAINER_COMPONENTS_INIT_URL=https://raw.githubusercontent.com/sustainable-computing-io/kepler-model-server/main/tests/test_models/DynComponentModelWeight/CgroupOnly/ScikitMixed/ScikitMixed.json" + data_map["EXPOSE_HW_COUNTER_METRICS"] = "true" + data_map["EXPOSE_CGROUP_METRICS"] = "true" r.configMap.Data = data_map return nil @@ -380,7 +382,7 @@ func (r *collectorReconciler) ensureDaemonSet(l klog.Logger) (bool, error) { Privileged: &scc_value, }, Image: image, - Command: []string{"/usr/bin/kepler", "-address", bindAddress, "-enable-gpu=true", "enable-cgroup-id=true", "v=5"}, + Command: []string{"/usr/bin/kepler", "-address", bindAddress, "-enable-gpu=true", "enable-cgroup-id=true", "v=5", "-kernel-source-dir=/usr/share/kepler/kernel_sources"}, Ports: []corev1.ContainerPort{{ ContainerPort: collectorPort, Name: "http", @@ -415,6 +417,15 @@ func (r *collectorReconciler) ensureDaemonSet(l klog.Logger) (bool, error) { {Name: "NODE_IP", ValueFrom: &envFromSource}, } + envFromSource = corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "spec.nodeName", + }, + } + r.daemonSet.Spec.Template.Spec.Containers[0].Env = []corev1.EnvVar{ + {Name: "NODE_NAME", ValueFrom: &envFromSource}, + } + r.daemonSet.Spec.Template.Spec.Containers[0].VolumeMounts = []corev1.VolumeMount{ {Name: "lib-modules", MountPath: "/lib/modules"}, {Name: "tracing", MountPath: "/sys"}, diff --git a/controllers/sahandler.go b/controllers/sahandler.go index be2c16c1..a018b2ed 100644 --- a/controllers/sahandler.go +++ b/controllers/sahandler.go @@ -130,7 +130,7 @@ func (d *keplerSADescription) createOrUpdateClusterRole(l klog.Logger) (*rbacv1. Rules: []rbacv1.PolicyRule{ { APIGroups: []string{""}, - Resources: []string{"nodes/metrics", "nodes/proxy", "nodes/stats"}, + Resources: []string{"nodes/metrics", "nodes/proxy", "nodes/stats", "pods"}, Verbs: []string{"get", "watch", "list"}, }, },