Skip to content

Commit

Permalink
🌱 Update hetznerbaremetalmachine_types.go (#1175)
Browse files Browse the repository at this point in the history
Update API descriptions of HetznerBareMetalMachine

Signed-off-by: Sayanta Banerjee <sayanta.banerjee@syself.com>
  • Loading branch information
Sayanta66 authored Mar 28, 2024
1 parent cdf777a commit 43063c6
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 106 deletions.
72 changes: 44 additions & 28 deletions api/v1beta1/hetznerbaremetalmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,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://bm-<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 @@ -77,85 +77,101 @@ 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.
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.
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 @@ -218,18 +234,18 @@ func (image Image) String() string {
// 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 @@ -287,11 +303,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 @@ -325,8 +325,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 @@ -347,7 +347,8 @@ 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.
properties:
name:
description: Name defines the archive name after download.
Expand Down Expand Up @@ -395,8 +396,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 @@ -408,16 +409,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 @@ -427,19 +428,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 @@ -483,32 +486,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
Loading

0 comments on commit 43063c6

Please sign in to comment.