Skip to content

Commit

Permalink
feat: add method enum (bcc,libbpf) to kepler spec and use this to cho…
Browse files Browse the repository at this point in the history
…ose corresponding image

Signed-off-by: Bastien Grasnick <bastien.grasnick@deutschebahn.com>
  • Loading branch information
BGrasnick committed Oct 23, 2023
1 parent ffcdd16 commit 7d2ba6d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ spec:
type: object
type: array
type: object
method:
default: bcc
enum:
- bcc
- libbpf
type: string
type: object
type: object
status:
Expand Down
1 change: 1 addition & 0 deletions config/samples/kepler.system_v1alpha1_kepler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ spec:
exporter:
deployment:
port: 9103
method: libbpf # bcc | libbpf

5 changes: 5 additions & 0 deletions pkg/api/v1alpha1/kepler_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion pkg/components/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7d2ba6d

Please sign in to comment.