Skip to content

Commit

Permalink
HostFirmwareComponents CRD and Controller
Browse files Browse the repository at this point in the history
- New Controller for HostFirmwareComponents
- Updated the CRD based on kustomization
- added GetFirmwareComponentsForNode to the Provisioner interface
- implemented GetFirmwareComponentsForNode in ironic.go

Signed-off-by: Iury Gregory Melo Ferreira <imelofer@redhat.com>
  • Loading branch information
iurygregory committed Feb 16, 2024
1 parent 5dc5e5f commit b9b63fc
Show file tree
Hide file tree
Showing 20 changed files with 664 additions and 20 deletions.
7 changes: 6 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: metal3.io
layout:
- go.kubebuilder.io/v3
Expand Down Expand Up @@ -64,9 +68,10 @@ resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: metal3.io
group: metal3.io
kind: HostFirmwareComponents
path: github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha
path: github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1
version: v1alpha1
version: "3"
8 changes: 3 additions & 5 deletions apis/metal3.io/v1alpha1/hostfirmwarecomponents_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// FirmwareUpdate defines a firmware update specification.
type FirmwareUpdate struct {
Component string `json:"component"`
Expand All @@ -34,9 +32,9 @@ type FirmwareUpdate struct {
type FirmwareComponentStatus struct {
Component string `json:"component"`
InitialVersion string `json:"initialVersion"`
CurrentVersion string `json:"currentVersion"`
LastVersionFlashed string `json:"lastVersionFlashed"`
UpdatedAt metav1.Time `json:"updatedAt"`
CurrentVersion string `json:"currentVersion,omitempty"`
LastVersionFlashed string `json:"lastVersionFlashed,omitempty"`
UpdatedAt metav1.Time `json:"updatedAt,omitempty"`
}

type UpdatesConditionType string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func TestValidateHostFirmwareComponents(t *testing.T) {
Component: "bios",
InitialVersion: "1.0",
CurrentVersion: "1.0",
UpdatedAt: metav1.NewTime(time.Now()),
},
{
Component: "bmc",
Expand Down
3 changes: 0 additions & 3 deletions config/base/crds/bases/metal3.io_hostfirmwarecomponents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ spec:
type: string
required:
- component
- currentVersion
- initialVersion
- lastVersionFlashed
- updatedAt
type: object
type: array
conditions:
Expand Down
3 changes: 3 additions & 0 deletions config/base/crds/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# It should be run by config/default
resources:
- bases/metal3.io_baremetalhosts.yaml
- bases/metal3.io_hostfirmwarecomponents.yaml
- bases/metal3.io_hostfirmwaresettings.yaml
- bases/metal3.io_firmwareschemas.yaml
- bases/metal3.io_preprovisioningimages.yaml
Expand All @@ -14,6 +15,7 @@ patches:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
#- patches/webhook_in_baremetalhosts.yaml
#- patches/webhook_in_hostfirmwarecomponents.yaml
#- patches/webhook_in_hostfirmwaresettings.yaml
#- patches/webhook_in_firmwareschemas.yaml
#- patches/webhook_in_preprovisioningimages.yaml
Expand All @@ -24,6 +26,7 @@ patches:
# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
- path: patches/cainjection_in_baremetalhosts.yaml
#- patches/cainjection_in_hostfirmwarecomponents.yaml
#- patches/cainjection_in_hostfirmwaresettings.yaml
#- patches/cainjection_in_firmwareschemas.yaml
#- patches/cainjection_in_preprovisioningimages.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: hostfirmwarecomponents.metal3.io
16 changes: 16 additions & 0 deletions config/base/crds/patches/webhook_in_hostfirmwarecomponents.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The following patch enables a conversion webhook for the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: hostfirmwarecomponents.metal3.io
spec:
conversion:
strategy: Webhook
webhook:
clientConfig:
service:
namespace: system
name: webhook-service
path: /convert
conversionReviewVersions:
- v1
17 changes: 12 additions & 5 deletions config/base/rbac/hostfirmwarecomponents_editor_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,30 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: hostfirmwarecomponents-editor-role
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: baremetal-operator
app.kubernetes.io/part-of: baremetal-operator
app.kubernetes.io/managed-by: kustomize
name: hostfirmwarecomponents-editor-role
rules:
- apiGroups:
- metal3.io
resources:
- hostfirmwarecomponents
verbs:
- create
- delete
- get
- list
- watch
- create
- update
- patch
- delete
- update
- watch
- apiGroups:
- metal3.io
resources:
- hostfirmwarecomponents/status
verbs:
- get
- get
11 changes: 9 additions & 2 deletions config/base/rbac/hostfirmwarecomponents_viewer_role.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# permissions for end users to edit hostfirmwarecomponents.
# permissions for end users to view hostfirmwarecomponents.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: clusterrole
app.kubernetes.io/instance: hostfirmwarecomponents-viewer-role
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: baremetal-operator
app.kubernetes.io/part-of: baremetal-operator
app.kubernetes.io/managed-by: kustomize
name: hostfirmwarecomponents-viewer-role
rules:
- apiGroups:
Expand All @@ -17,4 +24,4 @@ rules:
resources:
- hostfirmwarecomponents/status
verbs:
- get
- get
37 changes: 37 additions & 0 deletions config/base/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ rules:
- patch
- update
- watch
- apiGroups:
- metal3.io
resources:
- hostfirmwarecomponents
verbs:
- create
- get
- list
- patch
- update
- watch
- apiGroups:
- metal3.io
resources:
Expand Down Expand Up @@ -149,3 +160,29 @@ rules:
- get
- patch
- update
- apiGroups:
- metal3.io.metal3.io
resources:
- hostfirmwarecomponents
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- metal3.io.metal3.io
resources:
- hostfirmwarecomponents/finalizers
verbs:
- update
- apiGroups:
- metal3.io.metal3.io
resources:
- hostfirmwarecomponents/status
verbs:
- get
- patch
- update

0 comments on commit b9b63fc

Please sign in to comment.