Skip to content

Commit b0b437c

Browse files
Add biosVersion resource and controller
1 parent 110c781 commit b0b437c

27 files changed

+3038
-9
lines changed

PROJECT

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,12 @@ resources:
7979
kind: BIOSSettings
8080
path: github.com/ironcore-dev/metal-operator/api/v1alpha1
8181
version: v1alpha1
82+
- api:
83+
crdVersion: v1
84+
controller: true
85+
domain: ironcore.dev
86+
group: metal
87+
kind: BIOSVersion
88+
path: github.com/ironcore-dev/metal-operator/api/v1alpha1
89+
version: v1alpha1
8290
version: "3"

api/v1alpha1/biosversion_types.go

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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+
"github.com/stmcginnis/gofish/redfish"
8+
corev1 "k8s.io/api/core/v1"
9+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
10+
)
11+
12+
type BIOSVersionState string
13+
14+
const (
15+
// BIOSVersionStatePending specifies that the bios upgrade maintenance is waiting
16+
BIOSVersionStatePending BIOSVersionState = "Pending"
17+
// BIOSVersionStateInProgress specifies that upgrading bios is in progress.
18+
BIOSVersionStateInProgress BIOSVersionState = "Processing"
19+
// BIOSVersionStateApplied specifies that the bios upgrade maintenance has been completed.
20+
BIOSVersionStateCompleted BIOSVersionState = "Completed"
21+
// BIOSVersionStateFailed specifies that the bios upgrade maintenance has failed.
22+
BIOSVersionStateFailed BIOSVersionState = "Failed"
23+
)
24+
25+
// BIOSVersionSpec defines the desired state of BIOSVersion.
26+
type BIOSVersionSpec struct {
27+
// Spec specifies the spec for upgrading BIOS for specific serverRef.
28+
BIOSVersionSpec VersionSpec `json:"biosVersionSpec,omitempty"`
29+
30+
// BiosSettingsRef is a reference to a specific BIOSSettings object which holds settings for this version
31+
// we use this to avoid multiple BIOS related ref on Server resources.
32+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="BiosSettingsRef is immutable"
33+
BiosSettingsRef *corev1.LocalObjectReference `json:"biosSettingsRef,omitempty"`
34+
35+
// ServerRef is a reference to a specific server to apply bios upgrade 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+
ServerMaintenancePolicyType ServerMaintenancePolicy `json:"serverMaintenancePolicyType,omitempty"`
41+
42+
// ServerMaintenanceRef is a reference to a ServerMaintenance object that that Controller has requested for the referred server.
43+
ServerMaintenanceRef *corev1.ObjectReference `json:"serverMaintenanceRef,omitempty"`
44+
}
45+
46+
type VersionSpec struct {
47+
// Version contains BIOS version to upgrade
48+
// +required
49+
Version string `json:"version"`
50+
// An indication of whether the server's upgrade service should bypass vendor update policies
51+
ForceUpdate bool `json:"forceUpdate,omitempty"`
52+
// details regarding the image to use to upgrade to given bios version
53+
Image ImageSpec `json:"image,omitempty"`
54+
}
55+
56+
type ImageSpec struct {
57+
// ImageSecretRef is a reference to the Kubernetes Secret (of type SecretTypeBasicAuth) object that contains the credentials
58+
// to access the ImageURI. This secret includes sensitive information such as usernames and passwords.
59+
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"`
60+
// The network protocol that the server's update service uses to retrieve 'ImageURI'
61+
TransferProtocol string `json:"transferProtocol,omitempty"`
62+
// The URI of the software image to update/install."
63+
// +required
64+
URI string `json:"URI,omitempty"`
65+
}
66+
67+
// BIOSVersionStatus defines the observed state of BIOSVersion.
68+
type BIOSVersionStatus struct {
69+
// State represents the current state of the bios configuration task.
70+
State BIOSVersionState `json:"state,omitempty"`
71+
72+
// UpgradeTaskStatus contains the state of the Upgrade Task created by the BMC
73+
UpgradeTaskStatus *TaskStatus `json:"upgradeTaskStatus,omitempty"`
74+
// Conditions represents the latest available observations of the Bios version upgrade state.
75+
// +patchStrategy=merge
76+
// +patchMergeKey=type
77+
// +optional
78+
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
79+
}
80+
81+
type TaskStatus struct {
82+
TaskURI string `json:"taskURI,omitempty"`
83+
State redfish.TaskState `json:"taskState,omitempty"`
84+
PercentComplete int `json:"percentageComplete,omitempty"`
85+
}
86+
87+
// +kubebuilder:object:root=true
88+
// +kubebuilder:subresource:status
89+
// +kubebuilder:resource:scope=Cluster
90+
// +kubebuilder:printcolumn:name="BIOSVersion",type=string,JSONPath=`.spec.biosVersionSpec.version`
91+
// +kubebuilder:printcolumn:name="ForceUpdate",type=string,JSONPath=`.spec.biosVersionSpec.forceUpdate`
92+
// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state`
93+
// +kubebuilder:printcolumn:name="ServerRef",type=string,JSONPath=`.spec.serverRef.name`
94+
// +kubebuilder:printcolumn:name="ServerMaintenanceRef",type=string,JSONPath=`.spec.serverMaintenanceRef.name`
95+
96+
// BIOSVersion is the Schema for the biosversions API.
97+
type BIOSVersion struct {
98+
metav1.TypeMeta `json:",inline"`
99+
metav1.ObjectMeta `json:"metadata,omitempty"`
100+
101+
Spec BIOSVersionSpec `json:"spec,omitempty"`
102+
Status BIOSVersionStatus `json:"status,omitempty"`
103+
}
104+
105+
// +kubebuilder:object:root=true
106+
107+
// BIOSVersionList contains a list of BIOSVersion.
108+
type BIOSVersionList struct {
109+
metav1.TypeMeta `json:",inline"`
110+
metav1.ListMeta `json:"metadata,omitempty"`
111+
Items []BIOSVersion `json:"items"`
112+
}
113+
114+
func init() {
115+
SchemeBuilder.Register(&BIOSVersion{}, &BIOSVersionList{})
116+
}

api/v1alpha1/zz_generated.deepcopy.go

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

bmc/bmc.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ type BMC interface {
5454

5555
GetStorages(ctx context.Context, systemUUID string) ([]Storage, error)
5656

57+
UpgradeBiosVersion(
58+
ctx context.Context,
59+
UUID string,
60+
parameters *redfish.SimpleUpdateParameters,
61+
) (string, error, bool)
62+
63+
GetBiosUpgradeTask(
64+
ctx context.Context,
65+
taskURI string,
66+
) (*redfish.Task, error)
67+
5768
WaitForServerPowerState(ctx context.Context, systemUUID string, powerState redfish.PowerState) error
5869
}
5970

0 commit comments

Comments
 (0)