Skip to content

Commit e8a43ac

Browse files
create BIOSSetting Flows Resource and Controller
1 parent 09f5832 commit e8a43ac

26 files changed

+1826
-8
lines changed

PROJECT

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,12 @@ 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: BIOSSettingsFlow
99+
path: github.com/ironcore-dev/metal-operator/api/v1alpha1
100+
version: v1alpha1
93101
version: "3"

api/v1alpha1/biossettings_types.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ type BIOSSettingsSpec struct {
1818
// +optional
1919
SettingsMap map[string]string `json:"settings,omitempty"`
2020

21+
// SettingUpdatePolicy dictates how the settings are applied.
22+
// if 'Sequence', the BIOSSettings resource will enter 'Waiting' state after applying the settings
23+
// if 'OneShotUpdate' the BIOSSettings resource will enter 'Completed' state after applying the settings
24+
SettingUpdatePolicy SettingUpdatePolicy `json:"settingUpdatePolicy,omitempty"`
25+
26+
// CurrentSettingPriority specifies the number of sequence left to complete the settings workflow
27+
// used in conjunction with SettingUpdatePolicy and BIOSSettingFlow
28+
CurrentSettingPriority int32 `json:"currentSettingPriority,omitempty"`
29+
2130
// ServerRef is a reference to a specific server to apply bios setting on.
2231
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="serverRef is immutable"
2332
ServerRef *corev1.LocalObjectReference `json:"serverRef,omitempty"`
@@ -35,6 +44,8 @@ type BIOSSettingsState string
3544
const (
3645
// BIOSSettingsStatePending specifies that the bios setting maintenance is waiting
3746
BIOSSettingsStatePending BIOSSettingsState = "Pending"
47+
// BIOSSettingsStateInWaiting specifies that the BIOSSetting Controller is updating the settings
48+
BIOSSettingsStateInWaiting BIOSSettingsState = "Waiting"
3849
// BIOSSettingsStateInProgress specifies that the BIOSSetting Controller is updating the settings
3950
BIOSSettingsStateInProgress BIOSSettingsState = "InProgress"
4051
// BIOSSettingsStateApplied specifies that the bios setting maintenance has been completed.
@@ -43,6 +54,13 @@ const (
4354
BIOSSettingsStateFailed BIOSSettingsState = "Failed"
4455
)
4556

57+
type SettingUpdatePolicy string
58+
59+
const (
60+
SequencialUpdate SettingUpdatePolicy = "Sequence"
61+
OneShotUpdate SettingUpdatePolicy = "OneShotUpdate"
62+
)
63+
4664
type BIOSSettingUpdateState string
4765

4866
const (
@@ -63,12 +81,15 @@ type BIOSSettingsStatus struct {
6381
State BIOSSettingsState `json:"state,omitempty"`
6482
// UpdateSettingState represents the current state of the bios setting update task.
6583
UpdateSettingState BIOSSettingUpdateState `json:"updateSettingState,omitempty"`
84+
// AppliedSettingPriority specifies the number of sequence left to complete the settings workflow
85+
// used in conjunction with SettingUpdatePolicy and BIOSSettingFlow Resource
86+
AppliedSettingPriority int32 `json:"appliedSettingPriority,omitempty"`
6687
}
6788

6889
// +kubebuilder:object:root=true
6990
// +kubebuilder:subresource:status
7091
// +kubebuilder:resource:scope=Cluster
71-
// +kubebuilder:printcolumn:name="BIOSVersion",type=string,JSONPath=`.spec.biosSettings.version`
92+
// +kubebuilder:printcolumn:name="BIOSVersion",type=string,JSONPath=`.spec.version`
7293
// +kubebuilder:printcolumn:name="ServerRef",type=string,JSONPath=`.spec.serverRef.name`
7394
// +kubebuilder:printcolumn:name="ServerMaintenanceRef",type=string,JSONPath=`.spec.serverMaintenanceRef.name`
7495
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=`.status.state`
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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+
// BIOSSettingsState specifies the current state of the BIOS maintenance.
12+
type BIOSSettingsFlowState string
13+
14+
const (
15+
// BIOSSettingsFlowStatePending specifies that the bios setting maintenance is waiting
16+
BIOSSettingsFlowStatePending BIOSSettingsFlowState = "Pending"
17+
// BIOSSettingsFlowStateInProgress specifies that the BIOSSetting Controller is updating the settings
18+
BIOSSettingsFlowStateInProgress BIOSSettingsFlowState = "InProgress"
19+
// BIOSSettingsFlowStateApplied specifies that the bios setting maintenance has been completed.
20+
BIOSSettingsFlowStateApplied BIOSSettingsFlowState = "Applied"
21+
// BIOSSettingsFlowStateFailed specifies that the bios setting maintenance has failed.
22+
BIOSSettingsFlowStateFailed BIOSSettingsFlowState = "Failed"
23+
)
24+
25+
// BIOSSettingsFlowSpec defines the desired state of BIOSSettingsFlow.
26+
type BIOSSettingsFlowSpec struct {
27+
// Version contains software (eg: BIOS, BMC) version this settings applies to
28+
// +required
29+
Version string `json:"version"`
30+
31+
// SettingsFlow contains BIOS settings sequence to apply on the BIOS in given order
32+
// +optional
33+
SettingsFlow []SettingsFlowItem `json:"settingsFlow,omitempty"`
34+
35+
// ServerRef is a reference to a specific server to apply bios setting on.
36+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="serverRef is immutable"
37+
ServerRef *corev1.LocalObjectReference `json:"serverRef,omitempty"`
38+
39+
// ServerMaintenancePolicy is maintenance policy to be enforced on the server.
40+
ServerMaintenancePolicy ServerMaintenancePolicy `json:"serverMaintenancePolicy,omitempty"`
41+
}
42+
43+
type SettingsFlowItem struct {
44+
Settings map[string]string `json:"settings,omitempty"`
45+
// Priority defines the order of applying the settings
46+
// any int greater than 0. lower number have higher Priority (ie; lower number is applied first)
47+
Priority int32 `json:"priority"`
48+
}
49+
50+
// BIOSSettingsFlowStatus defines the observed state of BIOSSettingsFlow.
51+
type BIOSSettingsFlowStatus struct {
52+
// State represents the current state of the bios configuration task.
53+
State BIOSSettingsFlowState `json:"state,omitempty"`
54+
}
55+
56+
// +kubebuilder:object:root=true
57+
// +kubebuilder:subresource:status
58+
// +kubebuilder:resource:scope=Cluster
59+
// +kubebuilder:printcolumn:name="BIOSVersion",type=string,JSONPath=`.spec.version`
60+
// +kubebuilder:printcolumn:name="ServerRef",type=string,JSONPath=`.spec.serverRef.name`
61+
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=`.status.state`
62+
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
63+
64+
// BIOSSettingsFlow is the Schema for the biossettingsflows API.
65+
type BIOSSettingsFlow struct {
66+
metav1.TypeMeta `json:",inline"`
67+
metav1.ObjectMeta `json:"metadata,omitempty"`
68+
69+
Spec BIOSSettingsFlowSpec `json:"spec,omitempty"`
70+
Status BIOSSettingsFlowStatus `json:"status,omitempty"`
71+
}
72+
73+
// +kubebuilder:object:root=true
74+
75+
// BIOSSettingsFlowList contains a list of BIOSSettingsFlow.
76+
type BIOSSettingsFlowList struct {
77+
metav1.TypeMeta `json:",inline"`
78+
metav1.ListMeta `json:"metadata,omitempty"`
79+
Items []BIOSSettingsFlow `json:"items"`
80+
}
81+
82+
func init() {
83+
SchemeBuilder.Register(&BIOSSettingsFlow{}, &BIOSSettingsFlowList{})
84+
}

api/v1alpha1/zz_generated.deepcopy.go

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

cmd/manager/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,13 @@ func main() { // nolint: gocyclo
410410
os.Exit(1)
411411
}
412412
}
413+
if err = (&controller.BIOSSettingsFlowReconciler{
414+
Client: mgr.GetClient(),
415+
Scheme: mgr.GetScheme(),
416+
}).SetupWithManager(mgr); err != nil {
417+
setupLog.Error(err, "unable to create controller", "controller", "BIOSSettingsFlow")
418+
os.Exit(1)
419+
}
413420
//+kubebuilder:scaffold:builder
414421

415422
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {

config/crd/bases/metal.ironcore.dev_biossettings.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
scope: Cluster
1616
versions:
1717
- additionalPrinterColumns:
18-
- jsonPath: .spec.biosSettings.version
18+
- jsonPath: .spec.version
1919
name: BIOSVersion
2020
type: string
2121
- jsonPath: .spec.serverRef.name
@@ -55,6 +55,12 @@ spec:
5555
spec:
5656
description: BIOSSettingsSpec defines the desired state of BIOSSettings.
5757
properties:
58+
currentSettingPriority:
59+
description: |-
60+
CurrentSettingPriority specifies the number of sequence left to complete the settings workflow
61+
used in conjunction with SettingUpdatePolicy and BIOSSettingFlow
62+
format: int32
63+
type: integer
5864
serverMaintenancePolicy:
5965
description: ServerMaintenancePolicy is maintenance policy to be enforced
6066
on the server.
@@ -121,6 +127,12 @@ spec:
121127
x-kubernetes-validations:
122128
- message: serverRef is immutable
123129
rule: self == oldSelf
130+
settingUpdatePolicy:
131+
description: |-
132+
SettingUpdatePolicy dictates how the settings are applied.
133+
if 'Sequence', the BIOSSettings resource will enter 'Waiting' state after applying the settings
134+
if 'OneShotUpdate' the BIOSSettings resource will enter 'Completed' state after applying the settings
135+
type: string
124136
settings:
125137
additionalProperties:
126138
type: string
@@ -137,6 +149,12 @@ spec:
137149
status:
138150
description: BIOSSettingsStatus defines the observed state of BIOSSettings.
139151
properties:
152+
appliedSettingPriority:
153+
description: |-
154+
AppliedSettingPriority specifies the number of sequence left to complete the settings workflow
155+
used in conjunction with SettingUpdatePolicy and BIOSSettingFlow Resource
156+
format: int32
157+
type: integer
140158
state:
141159
description: State represents the current state of the bios configuration
142160
task.

0 commit comments

Comments
 (0)