Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Hardware resources and BMCRef #614

Merged
merged 1 commit into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions config/crd/bases/tinkerbell.org_hardware.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -318,6 +341,17 @@ spec:
state:
type: string
type: object
resources:
additionalProperties:
anyOf:
- type: integer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need clarification in the description on the assumed unit when specifying as an integer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In-fact I don't think that makes sense because describing a CPUs is a single number. Something still seems odd though, how are users meant to know what value to use?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, its a Kubernetes type which has its own documentation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CPUs can be fractional for K8s pods, or whole numbers. See the Format godoc example

Copy link
Member

@chrisdoherty4 chrisdoherty4 May 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but fractionality doesn't make sense in Tinkerbell. We only talk in terms of whole CPUs hence I'm wondering if we need to better define boundaries seeming as we're leveraging an existing type with behavior beyond our need.

I'd hate to see someone define a Hardware with .5m CPU for example and it seems like this is open to that sort of accidental usage.

Copy link
Member

@chrisdoherty4 chrisdoherty4 May 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, I agree this doesn't need additional documentation from my OP about units assumed with integers. I've shifted to "are our bounds adequately described" because the resource.Quantity supports stuff beyond what we want.

- 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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions pkg/apis/core/v1alpha1/hardware_types.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand Down Expand Up @@ -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"`

Expand All @@ -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
Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/core/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.