Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mount redfish credentials #191

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/components/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (
ServiceName = prefix + "svc"

StableImage = "quay.io/sustainable_computing_io/kepler:release-0.5.4"

RedfishSecretName = "redfish"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are we creating the secret ? 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the redfish secret is optional, how about we allow

exporter:
  redfish:
    secretRef: 

Also, why are we using secret instead of say configmap?

)

// Config that will be set from outside
Expand Down Expand Up @@ -166,7 +168,8 @@ func NewDaemonSet(detail components.Detail, k *v1alpha1.Kepler) *appsv1.DaemonSe
{Name: "kernel-src", MountPath: "/usr/src/kernels"},
{Name: "kernel-debug", MountPath: "/sys/kernel/debug"},
{Name: "proc", MountPath: "/proc"},
{Name: "cfm", MountPath: "/etc/kepler/kepler.config"},
{Name: "cfm", MountPath: "/etc/kepler/kepler.config", ReadOnly: true},
{Name: "redfish-cred", MountPath: "/etc/redfish", ReadOnly: true},
}, // VolumeMounts
}}, // Container: kepler / Containers
Volumes: []corev1.Volume{
Expand All @@ -175,6 +178,7 @@ func NewDaemonSet(detail components.Detail, k *v1alpha1.Kepler) *appsv1.DaemonSe
k8s.VolumeFromHost("proc", "/proc"),
k8s.VolumeFromHost("kernel-debug", "/sys/kernel/debug"),
k8s.VolumeFromHost("kernel-src", "/usr/src/kernels"),
k8s.VolumeFromSecret("redfish-cred", RedfishSecretName),
Copy link
Collaborator

@sthaha sthaha Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a related note, there is a down side to this that we should solve .. which is that secrets will be deleted when kepler is deleted :( ... Need to find a way to optionally delete ns if user created objects (including grafana exists).

k8s.VolumeFromConfigMap("cfm", ConfigmapName),
}, // Volumes
}, // PodSpec
Expand Down
13 changes: 13 additions & 0 deletions pkg/utils/k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/sustainable.computing.io/kepler-operator/pkg/api/v1alpha1"
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/pointer"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -75,6 +76,18 @@ func VolumeFromPVC(name, pvcName string) corev1.Volume {
}
}

func VolumeFromSecret(name, secretName string) corev1.Volume {
return corev1.Volume{
Name: name,
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: secretName,
Optional: pointer.Bool(true),
},
},
}
}

func EnvFromField(path string) *corev1.EnvVarSource {
return &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{FieldPath: path},
Expand Down