diff --git a/config/crd/bases/tinkerbell.org_hardware.yaml b/config/crd/bases/tinkerbell.org_hardware.yaml index 40b6f6aed..0a535e630 100644 --- a/config/crd/bases/tinkerbell.org_hardware.yaml +++ b/config/crd/bases/tinkerbell.org_hardware.yaml @@ -45,6 +45,29 @@ spec: spec: description: HardwareSpec defines the desired state of Hardware. properties: + bmcRef: + description: + BMCRef contains a relation to a BMC state management + type in the same namespace as the Hardware. This may be used for + BMC management by orchestrators. + properties: + apiGroup: + description: + APIGroup is the group for the resource being referenced. + If APIGroup is not specified, the specified Kind must be in + the core API group. For any other third-party types, APIGroup + is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + required: + - kind + - name + type: object disks: items: description: Disk represents a disk device for Tinkerbell Hardware. @@ -318,6 +341,17 @@ spec: state: type: string type: object + resources: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: + Resources represents known resources that are available + on a machine. Resources may be used for scheduling by orchestrators. + type: object tinkVersion: format: int64 type: integer diff --git a/go.mod b/go.mod index 0657e5439..2eec02a14 100644 --- a/go.mod +++ b/go.mod @@ -38,6 +38,7 @@ require ( google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 google.golang.org/protobuf v1.27.1 gopkg.in/yaml.v2 v2.4.0 + k8s.io/api v0.23.0 k8s.io/apimachinery v0.23.0 k8s.io/client-go v0.23.0 knative.dev/pkg v0.0.0-20211119170723-a99300deff34 @@ -160,7 +161,6 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.62.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect - k8s.io/api v0.23.0 // indirect k8s.io/apiextensions-apiserver v0.23.0 // indirect k8s.io/component-base v0.23.0 // indirect k8s.io/klog/v2 v2.60.1 // indirect diff --git a/pkg/apis/core/v1alpha1/hardware_types.go b/pkg/apis/core/v1alpha1/hardware_types.go index e95491e67..5b1037cb4 100644 --- a/pkg/apis/core/v1alpha1/hardware_types.go +++ b/pkg/apis/core/v1alpha1/hardware_types.go @@ -1,6 +1,8 @@ package v1alpha1 import ( + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -42,6 +44,12 @@ type Hardware struct { // HardwareSpec defines the desired state of Hardware. type HardwareSpec struct { + // BMCRef contains a relation to a BMC state management type in the same + // namespace as the Hardware. This may be used for BMC management by + // orchestrators. + //+optional + BMCRef *corev1.TypedLocalObjectReference `json:"bmcRef,omitempty"` + //+optional Interfaces []Interface `json:"interfaces,omitempty"` @@ -57,6 +65,11 @@ type HardwareSpec struct { //+optional Disks []Disk `json:"disks,omitempty"` + // Resources represents known resources that are available on a machine. + // Resources may be used for scheduling by orchestrators. + //+optional + Resources map[string]resource.Quantity `json:"resources,omitempty"` + // UserData is the user data to configure in the hardware's // metadata //+optional diff --git a/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go index ce95fc290..c4ae18542 100644 --- a/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/core/v1alpha1/zz_generated.deepcopy.go @@ -22,6 +22,8 @@ limitations under the License. package v1alpha1 import ( + "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -203,6 +205,11 @@ func (in *HardwareMetadata) DeepCopy() *HardwareMetadata { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HardwareSpec) DeepCopyInto(out *HardwareSpec) { *out = *in + if in.BMCRef != nil { + in, out := &in.BMCRef, &out.BMCRef + *out = new(v1.TypedLocalObjectReference) + (*in).DeepCopyInto(*out) + } if in.Interfaces != nil { in, out := &in.Interfaces, &out.Interfaces *out = make([]Interface, len(*in)) @@ -220,6 +227,13 @@ func (in *HardwareSpec) DeepCopyInto(out *HardwareSpec) { *out = make([]Disk, len(*in)) copy(*out, *in) } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make(map[string]resource.Quantity, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } if in.UserData != nil { in, out := &in.UserData, &out.UserData *out = new(string)