Skip to content

Commit 93f33d3

Browse files
Add BMCSettings type and controller implementation (#303)
* Add crd and controller for BMCSettings * change name to bmcSettings * Add reset bmc, improve controller logic * skip some lint check temporarily * Improve documentation for bmcSettings * Update design to accomodate difference vedor variations * merge conflict after rebase * request for maintenance all the time * Merge with latest Unit test helpers * expected merge changes with BIOSVersion CRD PR * Fix naming convenctions, factor out code and fix comments * Use requeAfter instead of reconcile error * Resolve merge conflicts with main * Change naming to ServerMaintenanceRefItem * resolve merge conflict with merge * regenerate genereted files * some code improvements * remove unwanted comments and newlines * Add webhook for `BMCSettings` resources (#322) * Add webhook for BMCSettings resources * remove serverRefList * Add delete logic in the webbhoob * fix some housekeeping stuff * Update the serverMaintenanceRef API field
1 parent 111a9c1 commit 93f33d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3591
-248
lines changed

PROJECT

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,15 @@ resources:
9090
webhooks:
9191
validation: true
9292
webhookVersion: v1
93+
- api:
94+
crdVersion: v1
95+
controller: true
96+
domain: ironcore.dev
97+
group: metal
98+
kind: BMCSettings
99+
path: github.com/ironcore-dev/metal-operator/api/v1alpha1
100+
version: v1alpha1
101+
webhooks:
102+
validation: true
103+
webhookVersion: v1
93104
version: "3"

api/v1alpha1/bmc_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ const (
2323
// BMCSpec defines the desired state of BMC
2424
// +kubebuilder:validation:XValidation:rule="has(self.access) != has(self.endpointRef)",message="exactly one of access or endpointRef needs to be set"
2525
type BMCSpec struct {
26+
27+
// bmcUUID is the unique identifier for the BMC as defined in REDFISH API.
28+
// +kubebuilder:validation:Optional
29+
// +optional
30+
// This field is optional and can be omitted, controller will choose the first avaialbe Manager
31+
BMCUUID string `json:"bmcUUID,omitempty"`
32+
2633
// EndpointRef is a reference to the Kubernetes object that contains the endpoint information for the BMC.
2734
// This reference is typically used to locate the BMC endpoint within the cluster.
2835
// +optional
@@ -49,6 +56,10 @@ type BMCSpec struct {
4956
// This field is optional and can be omitted if console access is not required.
5057
// +optional
5158
ConsoleProtocol *ConsoleProtocol `json:"consoleProtocol,omitempty"`
59+
60+
// BMCSettingRef is a reference to a BMCSettings object that specifies
61+
// the BMC configuration for this BMC.
62+
BMCSettingRef *v1.LocalObjectReference `json:"bmcSettingsRef,omitempty"`
5263
}
5364

5465
// InlineEndpoint defines inline network access configuration for the BMC.

api/v1alpha1/bmcsettings_types.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package v1alpha1
5+
6+
import (
7+
corev1 "k8s.io/api/core/v1"
8+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
9+
)
10+
11+
// BMCSettings refer's to Out-Of-Band_management like IDrac for Dell, iLo for HPE etc Settings
12+
13+
// BMCSettingsSpec defines the desired state of BMCSettings.
14+
type BMCSettingsSpec struct {
15+
// Version contains BMC version this settings applies to
16+
// +required
17+
Version string `json:"version"`
18+
19+
// SettingsMap contains bmc settings as map
20+
// +optional
21+
SettingsMap map[string]string `json:"settings,omitempty"`
22+
23+
// BMCRef is a reference to a specific BMC to apply setting to.
24+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="serverRef is immutable"
25+
BMCRef *corev1.LocalObjectReference `json:"BMCRef,omitempty"`
26+
27+
// ServerMaintenancePolicy is maintenance policy to be enforced on the server when applying setting.
28+
// ServerMaintenancePolicyOwnerApproval is asking for User approval for changing BMC settings
29+
// note: User approval is only enforced for server's which are reserved state
30+
// ServerMaintenancePolicyEnforced will will bypass user approval and apply setting directly
31+
ServerMaintenancePolicy ServerMaintenancePolicy `json:"serverMaintenancePolicy,omitempty"`
32+
33+
// ServerMaintenanceRefs are references to a ServerMaintenance objects that Controller has requested for the each of the related server.
34+
ServerMaintenanceRefs []ServerMaintenanceRefItem `json:"serverMaintenanceRefs,omitempty"`
35+
}
36+
37+
type ServerMaintenanceRefItem struct {
38+
ServerMaintenanceRef *corev1.ObjectReference `json:"serverMaintenanceRef,omitempty"`
39+
}
40+
41+
// ServerMaintenanceState specifies the current state of the server maintenance.
42+
type BMCSettingsState string
43+
44+
const (
45+
// BMCSettingsStatePending specifies that the BMC maintenance is waiting
46+
BMCSettingsStatePending BMCSettingsState = "Pending"
47+
// BMCSettingsStateInProgress specifies that the BMC setting changes are in progress
48+
BMCSettingsStateInProgress BMCSettingsState = "InProgress"
49+
// BMCSettingsStateApplied specifies that the BMC maintenance has been completed.
50+
BMCSettingsStateApplied BMCSettingsState = "Applied"
51+
// BMCSettingsStateFailed specifies that the BMC maintenance has failed.
52+
BMCSettingsStateFailed BMCSettingsState = "Failed"
53+
)
54+
55+
// BMCSettingsStatus defines the observed state of BMCSettings.
56+
type BMCSettingsStatus struct {
57+
// State represents the current state of the BMC configuration task.
58+
State BMCSettingsState `json:"state,omitempty"`
59+
}
60+
61+
// +kubebuilder:object:root=true
62+
// +kubebuilder:subresource:status
63+
// +kubebuilder:resource:scope=Cluster
64+
// +kubebuilder:printcolumn:name="BMCVersion",type=string,JSONPath=`.spec.bmcSettings.version`
65+
// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state`
66+
// +kubebuilder:printcolumn:name="BMCRef",type=string,JSONPath=`.spec.BMCRef.name`
67+
// +kubebuilder:printcolumn:name="ServerRef",type=string,JSONPath=`.spec.serverRef.name`
68+
69+
// BMCSettings is the Schema for the BMCSettings API.
70+
type BMCSettings struct {
71+
metav1.TypeMeta `json:",inline"`
72+
metav1.ObjectMeta `json:"metadata,omitempty"`
73+
74+
Spec BMCSettingsSpec `json:"spec,omitempty"`
75+
Status BMCSettingsStatus `json:"status,omitempty"`
76+
}
77+
78+
// +kubebuilder:object:root=true
79+
80+
// BMCSettingsList contains a list of BMCSettings.
81+
type BMCSettingsList struct {
82+
metav1.TypeMeta `json:",inline"`
83+
metav1.ListMeta `json:"metadata,omitempty"`
84+
Items []BMCSettings `json:"items"`
85+
}
86+
87+
func init() {
88+
SchemeBuilder.Register(&BMCSettings{}, &BMCSettingsList{})
89+
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 133 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)