Skip to content

Commit 6b0e0f1

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 6b0e0f1

13 files changed

+545
-121
lines changed

api/v1alpha7/openstackmachine_types.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ 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+
// +optional
8889
// +listType=map
8990
// +listMapKey=name
9091
AdditionalBlockDevices []AdditionalBlockDevice `json:"additionalBlockDevices,omitempty"`

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

+64-17
Original file line numberDiff line numberDiff line change
@@ -3771,30 +3771,77 @@ 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
37763776
items:
3777+
description: additionalBlockDevice is a block device to
3778+
attach to the server.
37773779
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
37863780
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.
3781+
description: name of the block device in the context
3782+
of a machine. If the block device is a volume, the
3783+
Cinder volume will be named as a combination of the
3784+
machine name and this name. Also, this name will be
3785+
used for tagging the block device. Information about
3786+
the block device tag can be obtained from the OpenStack
3787+
metadata API or the config drive.
37943788
type: string
3789+
sizeGiB:
3790+
description: sizeGiB is the size of the block device
3791+
in gibibytes (GiB).
3792+
minimum: 1
3793+
type: integer
3794+
storage:
3795+
description: storage specifies the storage type of the
3796+
block device and additional storage options.
3797+
properties:
3798+
type:
3799+
description: type is the type of block device to
3800+
create. This can be either "Volume" or "Local".
3801+
enum:
3802+
- Volume
3803+
- Local
3804+
type: string
3805+
volume:
3806+
description: volume contains additional storage
3807+
options for a volume block device.
3808+
properties:
3809+
availabilityZone:
3810+
description: availabilityZone is the volume
3811+
availability zone to create the volume in.
3812+
If omitted, the availability zone of the server
3813+
will be used. The availability zone must NOT
3814+
contain spaces otherwise it will lead to volume
3815+
that belongs to this availability zone register
3816+
failure, see kubernetes/cloud-provider-openstack#1379
3817+
for further information. The maximum length
3818+
of availability zone name is 63 as per labels
3819+
limits.
3820+
maxLength: 63
3821+
minLength: 1
3822+
type: string
3823+
x-kubernetes-validations:
3824+
- message: availabilityZone may not contain
3825+
spaces
3826+
rule: '!self.contains('' '')'
3827+
type:
3828+
description: type is the Cinder volume type
3829+
of the volume. If omitted, the default Cinder
3830+
volume type that is configured in the OpenStack
3831+
cloud will be used. The maximum length of
3832+
a volume type name is 255 characters, as per
3833+
the OpenStack limit.
3834+
maxLength: 255
3835+
minLength: 1
3836+
type: string
3837+
type: object
3838+
required:
3839+
- type
3840+
type: object
37953841
required:
3796-
- diskSize
37973842
- name
3843+
- sizeGiB
3844+
- storage
37983845
type: object
37993846
type: array
38003847
x-kubernetes-list-map-keys:

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

+69-20
Original file line numberDiff line numberDiff line change
@@ -1611,34 +1611,83 @@ spec:
16111611
description: Instance for the bastion itself
16121612
properties:
16131613
additionalBlockDevices:
1614-
description: AdditionalBlockDevices is a list of specifications
1614+
description: additionalBlockDevices is a list of specifications
16151615
for additional block devices to attach to the server
16161616
instance
16171617
items:
1618+
description: additionalBlockDevice is a block device
1619+
to attach to the server.
16181620
properties:
1619-
availabilityZone:
1620-
description: AvailabilityZone is the volume
1621-
availability zone to create the volume in.
1622-
If omitted, the availability zone of the server
1623-
will be used.
1624-
type: string
1625-
diskSize:
1626-
description: Size is the size in GB of the volume.
1627-
type: integer
16281621
name:
1629-
description: Name of the Cinder volume in the
1630-
context of a machine. It will be combined
1631-
with the machine name to make the actual volume
1632-
name.
1633-
type: string
1634-
volumeType:
1635-
description: VolumeType is the volume type of
1636-
the volume. If omitted, the default type will
1637-
be used.
1622+
description: name of the block device in the
1623+
context of a machine. If the block device
1624+
is a volume, the Cinder volume will be named
1625+
as a combination of the machine name and this
1626+
name. Also, this name will be used for tagging
1627+
the block device. Information about the block
1628+
device tag can be obtained from the OpenStack
1629+
metadata API or the config drive.
16381630
type: string
1631+
sizeGiB:
1632+
description: sizeGiB is the size of the block
1633+
device in gibibytes (GiB).
1634+
minimum: 1
1635+
type: integer
1636+
storage:
1637+
description: storage specifies the storage type
1638+
of the block device and additional storage
1639+
options.
1640+
properties:
1641+
type:
1642+
description: type is the type of block device
1643+
to create. This can be either "Volume"
1644+
or "Local".
1645+
enum:
1646+
- Volume
1647+
- Local
1648+
type: string
1649+
volume:
1650+
description: volume contains additional
1651+
storage options for a volume block device.
1652+
properties:
1653+
availabilityZone:
1654+
description: availabilityZone is the
1655+
volume availability zone to create
1656+
the volume in. If omitted, the availability
1657+
zone of the server will be used. The
1658+
availability zone must NOT contain
1659+
spaces otherwise it will lead to volume
1660+
that belongs to this availability
1661+
zone register failure, see kubernetes/cloud-provider-openstack#1379
1662+
for further information. The maximum
1663+
length of availability zone name is
1664+
63 as per labels limits.
1665+
maxLength: 63
1666+
minLength: 1
1667+
type: string
1668+
x-kubernetes-validations:
1669+
- message: availabilityZone may not
1670+
contain spaces
1671+
rule: '!self.contains('' '')'
1672+
type:
1673+
description: type is the Cinder volume
1674+
type of the volume. If omitted, the
1675+
default Cinder volume type that is
1676+
configured in the OpenStack cloud
1677+
will be used. The maximum length of
1678+
a volume type name is 255 characters,
1679+
as per the OpenStack limit.
1680+
maxLength: 255
1681+
minLength: 1
1682+
type: string
1683+
type: object
1684+
required:
1685+
- type
1686+
type: object
16391687
required:
1640-
- diskSize
16411688
- name
1689+
- sizeGiB
1690+
- storage
16421691
type: object
16431692
type: array
16441693
x-kubernetes-list-map-keys:

0 commit comments

Comments
 (0)