Skip to content

Commit

Permalink
馃尡 Update hetznerbaremetalhost_types.go (#1171)
Browse files Browse the repository at this point in the history
Update hetznerbaremetalhost_types.go
  • Loading branch information
Sayanta66 committed Feb 29, 2024
1 parent 6146bc3 commit 5142e6b
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 111 deletions.
13 changes: 10 additions & 3 deletions api/v1beta1/hetznerbaremetalhost_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ const (

// RootDeviceHints holds the hints for specifying the storage location
// for the root filesystem for the image. Need to specify either WWN or raid
// to provision host machine successfully.
// to provision the host machine successfully. It is important to find the correct root device.
// If none are specified, the host will stop provisioning in between to wait for
// the details to be specified. HardwareDetails in the host's status can be used to find the correct device.
// Currently, you can specify one disk or a raid setup.
type RootDeviceHints struct {
// Unique storage identifier. The hint must match the actual value
// exactly.
Expand Down Expand Up @@ -172,6 +175,7 @@ type RebootAnnotationArguments struct {
// HetznerBareMetalHostSpec defines the desired state of HetznerBareMetalHost.
type HetznerBareMetalHostSpec struct {
// ServerID defines the ID of the server provided by Hetzner.
// Find it on your Hetzner robot dashboard.
ServerID int `json:"serverID"`

// Provide guidance about how to choose the device for the image
Expand All @@ -188,11 +192,14 @@ type HetznerBareMetalHostSpec struct {
// and won't be selected by any Hetzner bare metal machine.
MaintenanceMode *bool `json:"maintenanceMode,omitempty"`

// Description is a human-entered text used to help identify the host
// Description is a human-entered text used to help identify the host.
// It can be used to store some valuable information about the host.
// +optional
Description string `json:"description,omitempty"`

// Status contains all status information. DO NOT EDIT!!!
// Status contains all status information. The controller writes this status.
// As some cannot be regenerated during any reconcilement, the status
// is in the specs of the object - not the actual status. DO NOT EDIT!!!
// +optional
Status ControllerGeneratedStatus `json:"status,omitempty"`
}
Expand Down
73 changes: 45 additions & 28 deletions api/v1beta1/hetznerbaremetalmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ const (

// HetznerBareMetalMachineSpec defines the desired state of HetznerBareMetalMachine.
type HetznerBareMetalMachineSpec struct {
// ProviderID will be the hetznerbaremetalmachine in ProviderID format
// (hcloud://<server-id>)
// ProviderID will be the hetznerbaremetalmachine which is set by the controller
// in the `hcloud://<server-id>` format.
// +optional
ProviderID *string `json:"providerID,omitempty"`

// InstallImage is the configuration which is used for the autosetup configuration for installing an OS via InstallImage.
// InstallImage is the configuration that is used for the autosetup configuration for installing an OS via InstallImage.
InstallImage InstallImage `json:"installImage"`

// HostSelector specifies matching criteria for labels on HetznerBareMetalHosts.
Expand All @@ -76,85 +76,102 @@ type HetznerBareMetalMachineSpec struct {
// +optional
HostSelector HostSelector `json:"hostSelector,omitempty"`

// SSHSpec gives a reference on the secret where SSH details are specified as well as ports for ssh.
// SSHSpec gives a reference on the secret where SSH details are specified as well as ports for SSH.
SSHSpec SSHSpec `json:"sshSpec,omitempty"`
}

// HostSelector specifies matching criteria for labels on BareMetalHosts.
// This is used to limit the set of BareMetalHost objects considered for
// claiming for a Machine.
type HostSelector struct {
// Key/value pairs of labels that must exist on a chosen BareMetalHost
// MatchLabels defines the key/value pairs of labels that must exist on a chosen BareMetalHost.
// +optional
MatchLabels map[string]string `json:"matchLabels,omitempty"`

// Label match expressions that must be true on a chosen BareMetalHost
// MatchExpressions defines the label match expressions that must be true on a chosen BareMetalHost.
// +optional
MatchExpressions []HostSelectorRequirement `json:"matchExpressions,omitempty"`
}

// HostSelectorRequirement defines a requirement used for MatchExpressions to select host machines.
type HostSelectorRequirement struct {
Key string `json:"key"`
// Key defines the key of the label that should be matched in the host object.
Key string `json:"key"`

// Operator defines the [selection operator](https://pkg.go.dev/k8s.io/apimachinery@v0.23.4/pkg/selection?utm_source=gopls#Operator).
Operator selection.Operator `json:"operator"`
Values []string `json:"values"`

// Values define the values whose relation to the label value in the host machine is defined by the selection operator.
Values []string `json:"values"`
}

// SSHSpec defines specs for SSH.
type SSHSpec struct {
// SecretRef gives reference to the secret.
// SecretRef gives reference to the secret where the SSH key is stored.
SecretRef SSHSecretRef `json:"secretRef"`

// PortAfterInstallImage specifies the port that has to be used to connect to the machine after install image.
// PortAfterInstallImage specifies the port that has to be used to connect to the machine
// by reaching the server via SSH after installing the image successfully.
// +kubebuilder:default=22
// +optional
PortAfterInstallImage int `json:"portAfterInstallImage"`

// PortAfterCloudInit specifies the port that has to be used to connect to the machine after cloud init.
// PortAfterCloudInit specifies the port that has to be used to connect to the machine
// by reaching the server via SSH after the successful completion of cloud init.
// +optional
PortAfterCloudInit int `json:"portAfterCloudInit"`
}

// SSHSecretRef defines the secret containing all information of the SSH key used for Hetzner robot.
// SSHSecretRef defines the secret containing all information of the SSH key used for the Hetzner robot.
type SSHSecretRef struct {
Name string `json:"name"`
Key SSHSecretKeyRef `json:"key"`
// Name is the name of the secret.
Name string `json:"name"`

// Key contains details about the keys used in the data of the secret.
Key SSHSecretKeyRef `json:"key"`
}

// SSHSecretKeyRef defines the key name of the SSHSecret.
type SSHSecretKeyRef struct {
Name string `json:"name"`
PublicKey string `json:"publicKey"`
// Name is the key in the secret's data where the SSH key's name is stored.
Name string `json:"name"`

// PublicKey is the key in the secret's data where the SSH key's public key is stored.
PublicKey string `json:"publicKey"`

// PrivateKey is the key in the secret's data where the SSH key's private key is stored.
PrivateKey string `json:"privateKey"`
}

// InstallImage defines the configuration for InstallImage.
type InstallImage struct {
// Image is the image to be provisioned.
// Image is the image to be provisioned. It defines the image
// for baremetal machine. Find more details on the image [here](https://github.com/syself/cluster-api-provider-hetzner/blob/main/docs/reference/hetzner-bare-metal-machine-template.md#installimageimage).
Image Image `json:"image"`

// PostInstallScript is used for configuring commands which should be executed after installimage.
// PostInstallScript is used for configuring commands that should be executed after installimage.
// It is passed along with the installimage command.
PostInstallScript string `json:"postInstallScript,omitempty"`

// Partitions defines the additional Partitions to be created.
// Partitions define the additional Partitions to be created in installimage.
Partitions []Partition `json:"partitions"`

// LVMDefinitions defines the logical volume definitions to be created.
// +optional
LVMDefinitions []LVMDefinition `json:"logicalVolumeDefinitions,omitempty"`

// BTRFSDefinitions defines the btrfs subvolume definitions to be created.
// BTRFSDefinitions define the btrfs subvolume definitions to be created.
// +optional
BTRFSDefinitions []BTRFSDefinition `json:"btrfsDefinitions,omitempty"`

// Swraid defines the SWRAID in InstallImage.
// Swraid defines the SWRAID in InstallImage. It enables or disables raids. Set 1 to enable.
// +optional
// +kubebuilder:default=0
// +kubebuilder:validation:Enum=0;1;
Swraid int `json:"swraid"`

// SwraidLevel defines the SWRAIDLEVEL in InstallImage. Ignored if Swraid=0.
// SwraidLevel defines the SWRAIDLEVEL in InstallImage. Only relevant if the raid is enabled.
// Pick one of 0,1,5,6,10. Ignored if Swraid=0.
// +optional
// +kubebuilder:default=1
// +kubebuilder:validation:Enum=0;1;5;6;10;
Expand Down Expand Up @@ -197,18 +214,18 @@ func (image Image) GetDetails() (imagePath string, needsDownload bool, errorMess
// Partition defines the additional Partitions to be created.
type Partition struct {
// Mount defines the mount path for this filesystem.
// or keyword 'lvm' to use this PART as volume group (VG) for LVM
// identifier 'btrfs.X' to use this PART as volume for
// Keyword 'lvm' to use this PART as volume group (VG) for LVM.
// Identifier 'btrfs.X' to use this PART as volume for
// btrfs subvolumes. X can be replaced with a unique
// alphanumeric keyword. NOTE: no support btrfs multi-device volumes
// alphanumeric keyword. NOTE: no support for btrfs multi-device volumes.
Mount string `json:"mount"`

// FileSystem can be ext2, ext3, ext4, btrfs, reiserfs, xfs, swap
// or name of the LVM volume group (VG), if this PART is a VG.
FileSystem string `json:"fileSystem"`

// Size can use the keyword 'all' to assign all the remaining space of the drive to the last partition.
// can use M/G/T for unit specification in MiB/GiB/TiB
// You can use M/G/T for unit specification in MiB/GiB/TiB.
Size string `json:"size"`
}

Expand Down Expand Up @@ -266,11 +283,11 @@ type HetznerBareMetalMachineStatus struct {
Ready bool `json:"ready"`

// Phase represents the current phase of HetznerBareMetalMachineStatus actuation.
// E.g. Pending, Running, Terminating, Failed etc.
// E.g. Pending, Running, Terminating, Failed, etc.
// +optional
Phase clusterv1.MachinePhase `json:"phase,omitempty"`

// Conditions defines current service state of the HetznerBareMetalMachine.
// Conditions define the current service state of the HetznerBareMetalMachine.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ spec:
x-kubernetes-map-type: atomic
description:
description: Description is a human-entered text used to help identify
the host
the host. It can be used to store some valuable information about
the host.
type: string
maintenanceMode:
description: MaintenanceMode indicates that a machine is supposed
Expand All @@ -145,9 +146,13 @@ spec:
type: object
serverID:
description: ServerID defines the ID of the server provided by Hetzner.
Find it on your Hetzner robot dashboard.
type: integer
status:
description: Status contains all status information. DO NOT EDIT!!!
description: Status contains all status information. The controller
writes this status. As some cannot be regenerated during any reconcilement,
the status is in the specs of the object - not the actual status.
DO NOT EDIT!!!
properties:
conditions:
description: Conditions defines current service state of the HetznerBareMetalHost.
Expand Down Expand Up @@ -313,8 +318,8 @@ spec:
the autosetup configuration for installing an OS via InstallImage.
properties:
btrfsDefinitions:
description: BTRFSDefinitions defines the btrfs subvolume
definitions to be created.
description: BTRFSDefinitions define the btrfs subvolume definitions
to be created.
items:
description: BTRFSDefinition defines the btrfs subvolume
definitions to be created.
Expand All @@ -335,7 +340,9 @@ spec:
type: object
type: array
image:
description: Image is the image to be provisioned.
description: Image is the image to be provisioned. It defines
the image for baremetal machine. Find more details on the
image [here](https://github.com/syself/cluster-api-provider-hetzner/blob/main/docs/reference/hetzner-bare-metal-machine-template.md#installimageimage).
properties:
name:
description: Name defines the archive name after download.
Expand Down Expand Up @@ -383,8 +390,8 @@ spec:
type: object
type: array
partitions:
description: Partitions defines the additional Partitions
to be created.
description: Partitions define the additional Partitions to
be created in installimage.
items:
description: Partition defines the additional Partitions
to be created.
Expand All @@ -396,16 +403,16 @@ spec:
type: string
mount:
description: 'Mount defines the mount path for this
filesystem. or keyword ''lvm'' to use this PART as
volume group (VG) for LVM identifier ''btrfs.X'' to
use this PART as volume for btrfs subvolumes. X can
be replaced with a unique alphanumeric keyword. NOTE:
no support btrfs multi-device volumes'
filesystem. Keyword ''lvm'' to use this PART as volume
group (VG) for LVM. Identifier ''btrfs.X'' to use
this PART as volume for btrfs subvolumes. X can be
replaced with a unique alphanumeric keyword. NOTE:
no support for btrfs multi-device volumes.'
type: string
size:
description: Size can use the keyword 'all' to assign
all the remaining space of the drive to the last partition.
can use M/G/T for unit specification in MiB/GiB/TiB
You can use M/G/T for unit specification in MiB/GiB/TiB.
type: string
required:
- fileSystem
Expand All @@ -415,19 +422,21 @@ spec:
type: array
postInstallScript:
description: PostInstallScript is used for configuring commands
which should be executed after installimage. It is passed
that should be executed after installimage. It is passed
along with the installimage command.
type: string
swraid:
default: 0
description: Swraid defines the SWRAID in InstallImage.
description: Swraid defines the SWRAID in InstallImage. It
enables or disables raids. Set 1 to enable.
enum:
- 0
- 1
type: integer
swraidLevel:
default: 1
description: SwraidLevel defines the SWRAIDLEVEL in InstallImage.
Only relevant if the raid is enabled. Pick one of 0,1,5,6,10.
Ignored if Swraid=0.
enum:
- 0
Expand Down Expand Up @@ -471,32 +480,42 @@ spec:
properties:
portAfterCloudInit:
description: PortAfterCloudInit specifies the port that has
to be used to connect to the machine after cloud init.
to be used to connect to the machine by reaching the server
via SSH after the successful completion of cloud init.
type: integer
portAfterInstallImage:
default: 22
description: PortAfterInstallImage specifies the port that
has to be used to connect to the machine after install image.
has to be used to connect to the machine by reaching the
server via SSH after installing the image successfully.
type: integer
secretRef:
description: SecretRef gives reference to the secret.
description: SecretRef gives reference to the secret where
the SSH key is stored.
properties:
key:
description: SSHSecretKeyRef defines the key name of the
SSHSecret.
description: Key contains details about the keys used
in the data of the secret.
properties:
name:
description: Name is the key in the secret's data
where the SSH key's name is stored.
type: string
privateKey:
description: PrivateKey is the key in the secret's
data where the SSH key's private key is stored.
type: string
publicKey:
description: PublicKey is the key in the secret's
data where the SSH key's public key is stored.
type: string
required:
- name
- privateKey
- publicKey
type: object
name:
description: Name is the name of the secret.
type: string
required:
- key
Expand Down

0 comments on commit 5142e6b

Please sign in to comment.