Skip to content

Commit f534622

Browse files
EmilienMmandre
andcommitted
Add ephemeral storage support to the AdditionalBlockDevices
Co-authored-by: Emilien Macchi <[email protected]> Co-authored-by: Martin André <[email protected]>
1 parent 3853737 commit f534622

13 files changed

+565
-124
lines changed

api/v1alpha7/openstackmachine_types.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,15 @@ type OpenStackMachineSpec struct {
8484
// The volume metadata to boot from
8585
RootVolume *RootVolume `json:"rootVolume,omitempty"`
8686

87-
// AdditionalBlockDevices is a list of specifications for additional block devices to attach to the server instance
87+
// additionalBlockDevices is a list of specifications for additional block devices to attach to the server instance
88+
//
89+
// + ---
90+
// While it's possible to have unlimited number of block devices attached to a server instance, the number is
91+
// limited to 255 to avoid rule cost exceeded error in CRD validation.
92+
// +kubebuilder:validation:MaxLength=255
8893
// +listType=map
8994
// +listMapKey=name
95+
// +optional
9096
AdditionalBlockDevices []AdditionalBlockDevice `json:"additionalBlockDevices,omitempty"`
9197

9298
// The server group to assign the machine to

api/v1alpha7/types.go

+71-10
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,81 @@ type RootVolume struct {
163163
AvailabilityZone string `json:"availabilityZone,omitempty"`
164164
}
165165

166-
type AdditionalBlockDevice struct {
167-
// Name of the Cinder volume in the context of a machine.
168-
// It will be combined with the machine name to make the actual volume name.
169-
Name string `json:"name"`
170-
// Size is the size in GB of the volume.
171-
Size int `json:"diskSize"`
172-
// VolumeType is the volume type of the volume.
173-
// If omitted, the default type will be used.
174-
VolumeType string `json:"volumeType,omitempty"`
175-
// AvailabilityZone is the volume availability zone to create the volume in.
166+
// blockDeviceStorage is the storage type of a block device to create and
167+
// contains additional storage options.
168+
// +union
169+
//
170+
//nolint:godot
171+
type BlockDeviceStorage struct {
172+
// type is the type of block device to create.
173+
// This can be either "Volume" or "Local".
174+
// +kubebuilder:validation:Enum="Volume";"Local"
175+
// +kubebuilder:validation:Required
176+
// +unionDiscriminator
177+
Type BlockDeviceType `json:"type"`
178+
179+
// volume contains additional storage options for a volume block device.
180+
// +optional
181+
Volume *BlockDeviceVolume `json:"volume,omitempty"`
182+
}
183+
184+
// blockDeviceVolume contains additional storage options for a volume block device.
185+
type BlockDeviceVolume struct {
186+
// type is the Cinder volume type of the volume.
187+
// If omitted, the default Cinder volume type that is configured in the OpenStack cloud
188+
// will be used.
189+
// The maximum length of a volume type name is 255 characters, as per the OpenStack limit.
190+
// +kubebuilder:validation:MinLength=1
191+
// +kubebuilder:validation:MaxLength=255
192+
// +optional
193+
Type string `json:"type,omitempty"`
194+
195+
// availabilityZone is the volume availability zone to create the volume in.
176196
// If omitted, the availability zone of the server will be used.
197+
// The availability zone must NOT contain spaces otherwise it will lead to volume that belongs
198+
// to this availability zone register failure, see kubernetes/cloud-provider-openstack#1379 for
199+
// further information.
200+
// The maximum length of availability zone name is 63 as per labels limits.
201+
// +kubebuilder:validation:MinLength=1
202+
// +kubebuilder:validation:MaxLength=63
203+
// +kubebuilder:validation:XValidation:rule="!self.contains(' ')",message="availabilityZone may not contain spaces"
204+
// +optional
177205
AvailabilityZone string `json:"availabilityZone,omitempty"`
178206
}
179207

208+
// additionalBlockDevice is a block device to attach to the server.
209+
type AdditionalBlockDevice struct {
210+
// name of the block device in the context of a machine.
211+
// If the block device is a volume, the Cinder volume will be named
212+
// as a combination of the machine name and this name.
213+
// Also, this name will be used for tagging the block device.
214+
// Information about the block device tag can be obtained from the OpenStack
215+
// metadata API or the config drive.
216+
// +kubebuilder:validation:Required
217+
Name string `json:"name"`
218+
219+
// sizeGiB is the size of the block device in gibibytes (GiB).
220+
// +kubebuilder:validation:Minimum=1
221+
// +kubebuilder:validation:Required
222+
SizeGiB int `json:"sizeGiB"`
223+
224+
// storage specifies the storage type of the block device and
225+
// additional storage options.
226+
// +kubebuilder:validation:Required
227+
Storage BlockDeviceStorage `json:"storage"`
228+
}
229+
230+
// BlockDeviceType defines the type of block device to create.
231+
type BlockDeviceType string
232+
233+
const (
234+
// LocalBlockDevice is an ephemeral block device attached to the server.
235+
LocalBlockDevice BlockDeviceType = "Local"
236+
237+
// VolumeBlockDevice is a volume block device attached to the server.
238+
VolumeBlockDevice BlockDeviceType = "Volume"
239+
)
240+
180241
// NetworkStatus contains basic information about an existing neutron network.
181242
type NetworkStatus struct {
182243
Name string `json:"name"`

api/v1alpha7/zz_generated.deepcopy.go

+39-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml

+67-17
Original file line numberDiff line numberDiff line change
@@ -3771,30 +3771,80 @@ spec:
37713771
description: Instance for the bastion itself
37723772
properties:
37733773
additionalBlockDevices:
3774-
description: AdditionalBlockDevices is a list of specifications
3774+
description: "additionalBlockDevices is a list of specifications
37753775
for additional block devices to attach to the server instance
3776+
\n While it's possible to have unlimited number of block
3777+
devices attached to a server instance, the number is limited
3778+
to 255 to avoid rule cost exceeded error in CRD validation."
37763779
items:
3780+
description: additionalBlockDevice is a block device to
3781+
attach to the server.
37773782
properties:
3778-
availabilityZone:
3779-
description: AvailabilityZone is the volume availability
3780-
zone to create the volume in. If omitted, the availability
3781-
zone of the server will be used.
3782-
type: string
3783-
diskSize:
3784-
description: Size is the size in GB of the volume.
3785-
type: integer
37863783
name:
3787-
description: Name of the Cinder volume in the context
3788-
of a machine. It will be combined with the machine
3789-
name to make the actual volume name.
3790-
type: string
3791-
volumeType:
3792-
description: VolumeType is the volume type of the volume.
3793-
If omitted, the default type will be used.
3784+
description: name of the block device in the context
3785+
of a machine. If the block device is a volume, the
3786+
Cinder volume will be named as a combination of the
3787+
machine name and this name. Also, this name will be
3788+
used for tagging the block device. Information about
3789+
the block device tag can be obtained from the OpenStack
3790+
metadata API or the config drive.
37943791
type: string
3792+
sizeGiB:
3793+
description: sizeGiB is the size of the block device
3794+
in gibibytes (GiB).
3795+
minimum: 1
3796+
type: integer
3797+
storage:
3798+
description: storage specifies the storage type of the
3799+
block device and additional storage options.
3800+
properties:
3801+
type:
3802+
description: type is the type of block device to
3803+
create. This can be either "Volume" or "Local".
3804+
enum:
3805+
- Volume
3806+
- Local
3807+
type: string
3808+
volume:
3809+
description: volume contains additional storage
3810+
options for a volume block device.
3811+
properties:
3812+
availabilityZone:
3813+
description: availabilityZone is the volume
3814+
availability zone to create the volume in.
3815+
If omitted, the availability zone of the server
3816+
will be used. The availability zone must NOT
3817+
contain spaces otherwise it will lead to volume
3818+
that belongs to this availability zone register
3819+
failure, see kubernetes/cloud-provider-openstack#1379
3820+
for further information. The maximum length
3821+
of availability zone name is 63 as per labels
3822+
limits.
3823+
maxLength: 63
3824+
minLength: 1
3825+
type: string
3826+
x-kubernetes-validations:
3827+
- message: availabilityZone may not contain
3828+
spaces
3829+
rule: '!self.contains('' '')'
3830+
type:
3831+
description: type is the Cinder volume type
3832+
of the volume. If omitted, the default Cinder
3833+
volume type that is configured in the OpenStack
3834+
cloud will be used. The maximum length of
3835+
a volume type name is 255 characters, as per
3836+
the OpenStack limit.
3837+
maxLength: 255
3838+
minLength: 1
3839+
type: string
3840+
type: object
3841+
required:
3842+
- type
3843+
type: object
37953844
required:
3796-
- diskSize
37973845
- name
3846+
- sizeGiB
3847+
- storage
37983848
type: object
37993849
type: array
38003850
x-kubernetes-list-map-keys:

0 commit comments

Comments
 (0)