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

POWERMON-235: Add support for Redfish #364

Merged
Merged
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
4 changes: 3 additions & 1 deletion bundle/manifests/kepler-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ metadata:
capabilities: Basic Install
categories: Monitoring
containerImage: quay.io/sustainable_computing_io/kepler-operator:0.10.0
createdAt: "2024-02-15T04:47:16Z"
createdAt: "2024-03-01T19:29:40Z"
description: 'Deploys and Manages Kepler on Kubernetes '
operators.operatorframework.io/builder: operator-sdk-v1.27.0
operators.operatorframework.io/internal-objects: |-
Expand Down Expand Up @@ -117,6 +117,7 @@ spec:
resources:
- daemonsets
- deployments
- secrets
verbs:
- create
- delete
Expand Down Expand Up @@ -155,6 +156,7 @@ spec:
- nodes/metrics
- nodes/proxy
- nodes/stats
- secrets
verbs:
- get
- list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,25 @@ spec:
- image
- namespace
type: object
redfish:
description: RedfishSpec for connecting to Redfish API
properties:
probeInterval:
description: ProbeInterval controls how frequently power info
is queried from Redfish
type: string
secretRef:
description: SecretRef refers to the name of secret which
contains credentials to initialize RedfishClient
type: string
skipSSLVerify:
default: false
description: SkipSSLVerify controls if RedfishClient will
skip verifying server
type: boolean
required:
- secretRef
type: object
required:
- deployment
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,25 @@ spec:
type: object
type: array
type: object
redfish:
description: RedfishSpec for connecting to Redfish API
properties:
probeInterval:
description: ProbeInterval controls how frequently power info
is queried from Redfish
type: string
secretRef:
description: SecretRef refers to the name of secret which
contains credentials to initialize RedfishClient
type: string
skipSSLVerify:
default: false
description: SkipSSLVerify controls if RedfishClient will
skip verifying server
type: boolean
required:
- secretRef
type: object
type: object
type: object
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,25 @@ spec:
- image
- namespace
type: object
redfish:
description: RedfishSpec for connecting to Redfish API
properties:
probeInterval:
description: ProbeInterval controls how frequently power info
is queried from Redfish
type: string
secretRef:
description: SecretRef refers to the name of secret which
contains credentials to initialize RedfishClient
type: string
skipSSLVerify:
default: false
description: SkipSSLVerify controls if RedfishClient will
skip verifying server
type: boolean
required:
- secretRef
type: object
required:
- deployment
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,25 @@ spec:
type: object
type: array
type: object
redfish:
description: RedfishSpec for connecting to Redfish API
properties:
probeInterval:
description: ProbeInterval controls how frequently power info
is queried from Redfish
type: string
secretRef:
description: SecretRef refers to the name of secret which
contains credentials to initialize RedfishClient
type: string
skipSSLVerify:
default: false
description: SkipSSLVerify controls if RedfishClient will
skip verifying server
type: boolean
required:
- secretRef
type: object
type: object
type: object
status:
Expand Down
2 changes: 2 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ rules:
resources:
- daemonsets
- deployments
- secrets
Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't create secrets do we ?

verbs:
- create
- delete
Expand Down Expand Up @@ -47,6 +48,7 @@ rules:
- nodes/metrics
- nodes/proxy
- nodes/stats
- secrets
verbs:
- get
- list
Expand Down
100 changes: 100 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ KeplerInternalSpec defines the desired state of KeplerInternal
<br/>
</td>
<td>true</td>
</tr><tr>
<td><b><a href="#keplerinternalspecexporterredfish">redfish</a></b></td>
<td>object</td>
<td>
RedfishSpec for connecting to Redfish API<br/>
</td>
<td>false</td>
</tr></tbody>
</table>

Expand Down Expand Up @@ -265,6 +272,49 @@ The pod this Toleration is attached to tolerates any taint that matches the trip
</table>


### KeplerInternal.spec.exporter.redfish
<sup><sup>[↩ Parent](#keplerinternalspecexporter)</sup></sup>



RedfishSpec for connecting to Redfish API

<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Required</th>
</tr>
</thead>
<tbody><tr>
<td><b>secretRef</b></td>
<td>string</td>
<td>
SecretRef refers to the name of secret which contains credentials to initialize RedfishClient<br/>
</td>
<td>true</td>
</tr><tr>
<td><b>probeInterval</b></td>
<td>string</td>
<td>
ProbeInterval controls how frequently power info is queried from Redfish<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>skipSSLVerify</b></td>
<td>boolean</td>
<td>
SkipSSLVerify controls if RedfishClient will skip verifying server<br/>
<br/>
<i>Default</i>: false<br/>
</td>
<td>false</td>
</tr></tbody>
</table>


### KeplerInternal.spec.estimator
<sup><sup>[↩ Parent](#keplerinternalspec)</sup></sup>

Expand Down Expand Up @@ -1518,6 +1568,13 @@ KeplerSpec defines the desired state of Kepler
<br/>
</td>
<td>false</td>
</tr><tr>
<td><b><a href="#keplerspecexporterredfish">redfish</a></b></td>
<td>object</td>
<td>
RedfishSpec for connecting to Redfish API<br/>
</td>
<td>false</td>
</tr></tbody>
</table>

Expand Down Expand Up @@ -1629,6 +1686,49 @@ The pod this Toleration is attached to tolerates any taint that matches the trip
</table>


### Kepler.spec.exporter.redfish
<sup><sup>[↩ Parent](#keplerspecexporter)</sup></sup>



RedfishSpec for connecting to Redfish API

<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Required</th>
</tr>
</thead>
<tbody><tr>
<td><b>secretRef</b></td>
<td>string</td>
<td>
SecretRef refers to the name of secret which contains credentials to initialize RedfishClient<br/>
</td>
<td>true</td>
</tr><tr>
<td><b>probeInterval</b></td>
<td>string</td>
<td>
ProbeInterval controls how frequently power info is queried from Redfish<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>skipSSLVerify</b></td>
<td>boolean</td>
<td>
SkipSSLVerify controls if RedfishClient will skip verifying server<br/>
<br/>
<i>Default</i>: false<br/>
</td>
<td>false</td>
</tr></tbody>
</table>


### Kepler.status
<sup><sup>[↩ Parent](#kepler)</sup></sup>

Expand Down
2 changes: 2 additions & 0 deletions pkg/api/v1alpha1/kepler_internal_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type InternalExporterDeploymentSpec struct {
type InternalExporterSpec struct {
// +kubebuilder:validation:Required
Deployment InternalExporterDeploymentSpec `json:"deployment"`

Redfish *RedfishSpec `json:"redfish,omitempty"`
}

type DashboardSpec struct {
Expand Down
17 changes: 17 additions & 0 deletions pkg/api/v1alpha1/kepler_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,25 @@ type ExporterDeploymentSpec struct {
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
}

// RedfishSpec for connecting to Redfish API
type RedfishSpec struct {
// SecretRef refers to the name of secret which contains credentials to initialize RedfishClient
SecretRef string `json:"secretRef"`

// ProbeInterval controls how frequently power info is queried from Redfish
// +optional
ProbeInterval metav1.Duration `json:"probeInterval,omitempty"`

// SkipSSLVerify controls if RedfishClient will skip verifying server
// +optional
// +kubebuilder:validation:Required
// +kubebuilder:default:=false
SkipSSLVerify bool `json:"skipSSLVerify,omitempty"`
}

type ExporterSpec struct {
Deployment ExporterDeploymentSpec `json:"deployment,omitempty"`
Redfish *RedfishSpec `json:"redfish,omitempty"`
}

// KeplerSpec defines the desired state of Kepler
Expand Down
26 changes: 26 additions & 0 deletions pkg/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion pkg/components/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ const (
overviewDashboardName = "power-monitoring-overview"
nsInfoDashboardName = "power-monitoring-by-ns"
DashboardNs = "openshift-config-managed"
REDFISH_ARGS = "-redfish-cred-file-path=/etc/redfish/redfish.csv"
REDFISH_CSV = "redfish.csv"
REDFISH_ANNOTATION = "kepler.system.sustainable.computing.io/redfish-secret-ref"
Comment on lines +48 to +50
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you please change this to follow the convention?
If these constants aren't used outside the package, lets make them private.


IdxKeplerContainer = 0
)

var (
Expand Down Expand Up @@ -132,6 +137,19 @@ func NewDaemonSet(detail components.Detail, k *v1alpha1.KeplerInternal) *appsv1.
}
}

func MountRedfishSecretToDaemonSet(ds *appsv1.DaemonSet, secret *corev1.Secret) {
spec := ds.Spec.Template.Spec
spec.Containers[IdxKeplerContainer].Command = append(spec.Containers[IdxKeplerContainer].Command, REDFISH_ARGS)
spec.Containers[IdxKeplerContainer].VolumeMounts = append(spec.Containers[IdxKeplerContainer].VolumeMounts,
corev1.VolumeMount{Name: "redfish-cred", MountPath: "/etc/redfish", ReadOnly: true})
spec.Volumes = append(spec.Volumes,
k8s.VolumeFromSecret("redfish-cred", secret.ObjectMeta.Name))
ds.Spec.Template.Spec = spec
ds.Spec.Template.Annotations = map[string]string{
REDFISH_ANNOTATION: secret.ResourceVersion,
}
Comment on lines +148 to +150
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it may be sufficient to just annotate the ds instead of the template. Lets handle this in a different PR.

}

func openshiftDashboardObjectMeta(name string) metav1.ObjectMeta {
return metav1.ObjectMeta{
Name: name,
Expand Down Expand Up @@ -377,6 +395,7 @@ func NewSCC(d components.Detail, ki *v1alpha1.KeplerInternal) *secv1.SecurityCon
Users: []string{ki.FQServiceAccountName()},
Volumes: []secv1.FSType{
secv1.FSType("configMap"),
secv1.FSType("secret"),
secv1.FSType("projected"),
secv1.FSType("emptyDir"),
secv1.FSType("hostPath")},
Expand Down Expand Up @@ -596,7 +615,6 @@ func newExporterContainer(kiName, dsName string, deployment v1alpha1.InternalExp
"-enable-gpu=$(ENABLE_GPU)",
"-v=$(KEPLER_LOG_LEVEL)",
"-kernel-source-dir=/usr/share/kepler/kernel_sources",
"-redfish-cred-file-path=/etc/redfish/redfish.csv",
},
Ports: []corev1.ContainerPort{{
ContainerPort: int32(deployment.Port),
Expand Down
Loading
Loading