diff --git a/config/crd/bases/kepler.system.sustainable.computing.io_keplers.yaml b/config/crd/bases/kepler.system.sustainable.computing.io_keplers.yaml index a53ac4de..7b5dd49c 100644 --- a/config/crd/bases/kepler.system.sustainable.computing.io_keplers.yaml +++ b/config/crd/bases/kepler.system.sustainable.computing.io_keplers.yaml @@ -129,6 +129,12 @@ spec: type: object type: array type: object + method: + default: bcc + enum: + - bcc + - libbpf + type: string type: object type: object status: diff --git a/config/samples/kepler.system_v1alpha1_kepler.yaml b/config/samples/kepler.system_v1alpha1_kepler.yaml index 4987cc2d..36eea553 100644 --- a/config/samples/kepler.system_v1alpha1_kepler.yaml +++ b/config/samples/kepler.system_v1alpha1_kepler.yaml @@ -10,4 +10,5 @@ spec: exporter: deployment: port: 9103 + method: libbpf # bcc | libbpf diff --git a/pkg/api/v1alpha1/kepler_types.go b/pkg/api/v1alpha1/kepler_types.go index 1a927548..a3cc3ab0 100644 --- a/pkg/api/v1alpha1/kepler_types.go +++ b/pkg/api/v1alpha1/kepler_types.go @@ -111,6 +111,11 @@ type ExporterDeploymentSpec struct { type ExporterSpec struct { Deployment ExporterDeploymentSpec `json:"deployment,omitempty"` + + // +kubebuilder:default="bcc" + // +kubebuilder:validation:Type=string + // +kubebuilder:validation:Enum={"bcc","libbpf"} + Method string `json:"method,omitempty"` } // KeplerSpec defines the desired state of Kepler diff --git a/pkg/components/exporter/exporter.go b/pkg/components/exporter/exporter.go index e2534bd3..7df1f539 100644 --- a/pkg/components/exporter/exporter.go +++ b/pkg/components/exporter/exporter.go @@ -106,6 +106,17 @@ func NewDaemonSet(detail components.Detail, k *v1alpha1.Kepler) *appsv1.DaemonSe bindAddress := "0.0.0.0:" + strconv.Itoa(int(deployment.Port)) + configImage := Config.Image + + if configImage == "" { + configImage = "quay.io/sustainable_computing_io/kepler:release-0.6.1" + } + + switch k.Spec.Exporter.Method { + case "libbpf": + configImage += "-libbpf" + } + return &appsv1.DaemonSet{ TypeMeta: metav1.TypeMeta{ APIVersion: appsv1.SchemeGroupVersion.String(), @@ -133,7 +144,7 @@ func NewDaemonSet(detail components.Detail, k *v1alpha1.Kepler) *appsv1.DaemonSe Containers: []corev1.Container{{ Name: "kepler-exporter", SecurityContext: &corev1.SecurityContext{Privileged: pointer.Bool(true)}, - Image: Config.Image, + Image: configImage, Command: []string{ "/usr/bin/kepler", "-address", bindAddress,