@@ -163,20 +163,83 @@ type RootVolume struct {
163
163
AvailabilityZone string `json:"availabilityZone,omitempty"`
164
164
}
165
165
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"`
166
+ // BlockDeviceStorage is the storage type of a block device to create and
167
+ // contains additional storage options.
168
+ // +kubebuilder:validation:XValidation:rule="self.type == 'Volume' || !has(self.volume)",message="volume is forbidden when type is not Volume"
169
+ // +union
170
+ //
171
+ //nolint:godot
172
+ type BlockDeviceStorage struct {
173
+ // Type is the type of block device to create.
174
+ // This can be either "Volume" or "Local".
175
+ // +kubebuilder:validation:Enum="Volume";"Local"
176
+ // +kubebuilder:validation:Required
177
+ // +unionDiscriminator
178
+ Type BlockDeviceType `json:"type"`
179
+
180
+ // Volume contains additional storage options for a volume block device.
181
+ // +optional
182
+ // +unionMember,optional
183
+ Volume * BlockDeviceVolume `json:"volume,omitempty"`
184
+ }
185
+
186
+ // BlockDeviceVolume contains additional storage options for a volume block device.
187
+ type BlockDeviceVolume struct {
188
+ // Type is the Cinder volume type of the volume.
189
+ // If omitted, the default Cinder volume type that is configured in the OpenStack cloud
190
+ // will be used.
191
+ // The maximum length of a volume type name is 255 characters, as per the OpenStack limit.
192
+ // +kubebuilder:validation:MinLength=1
193
+ // +kubebuilder:validation:MaxLength=255
194
+ // +optional
195
+ Type string `json:"type,omitempty"`
196
+
175
197
// AvailabilityZone is the volume availability zone to create the volume in.
176
198
// If omitted, the availability zone of the server will be used.
199
+ // The availability zone must NOT contain spaces otherwise it will lead to volume that belongs
200
+ // to this availability zone register failure, see kubernetes/cloud-provider-openstack#1379 for
201
+ // further information.
202
+ // The maximum length of availability zone name is 63 as per labels limits.
203
+ // +kubebuilder:validation:MinLength=1
204
+ // +kubebuilder:validation:MaxLength=63
205
+ // +kubebuilder:validation:XValidation:rule="!self.contains(' ')",message="availabilityZone may not contain spaces"
206
+ // +optional
177
207
AvailabilityZone string `json:"availabilityZone,omitempty"`
178
208
}
179
209
210
+ // AdditionalBlockDevice is a block device to attach to the server.
211
+ type AdditionalBlockDevice struct {
212
+ // Name of the block device in the context of a machine.
213
+ // If the block device is a volume, the Cinder volume will be named
214
+ // as a combination of the machine name and this name.
215
+ // Also, this name will be used for tagging the block device.
216
+ // Information about the block device tag can be obtained from the OpenStack
217
+ // metadata API or the config drive.
218
+ // +kubebuilder:validation:Required
219
+ Name string `json:"name"`
220
+
221
+ // SizeGiB is the size of the block device in gibibytes (GiB).
222
+ // +kubebuilder:validation:Minimum=1
223
+ // +kubebuilder:validation:Required
224
+ SizeGiB int `json:"sizeGiB"`
225
+
226
+ // Storage specifies the storage type of the block device and
227
+ // additional storage options.
228
+ // +kubebuilder:validation:Required
229
+ Storage BlockDeviceStorage `json:"storage"`
230
+ }
231
+
232
+ // BlockDeviceType defines the type of block device to create.
233
+ type BlockDeviceType string
234
+
235
+ const (
236
+ // LocalBlockDevice is an ephemeral block device attached to the server.
237
+ LocalBlockDevice BlockDeviceType = "Local"
238
+
239
+ // VolumeBlockDevice is a volume block device attached to the server.
240
+ VolumeBlockDevice BlockDeviceType = "Volume"
241
+ )
242
+
180
243
// NetworkStatus contains basic information about an existing neutron network.
181
244
type NetworkStatus struct {
182
245
Name string `json:"name"`
0 commit comments