Skip to content

Commit fdaa487

Browse files
committed
Server: Allow attaching volumes
Add a new mutable `volumes` fields in the server resource spec, allowing to control volumes attached to the server.
1 parent 522e201 commit fdaa487

File tree

24 files changed

+893
-37
lines changed

24 files changed

+893
-37
lines changed

api/v1alpha1/server_types.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,27 @@ type ServerPortSpec struct {
6060
PortRef *KubernetesNameRef `json:"portRef,omitempty"`
6161
}
6262

63+
// +kubebuilder:validation:MinProperties:=1
64+
type ServerVolumeSpec struct {
65+
// volumeRef is a reference to a Volume object. Server creation will wait for
66+
// this volume to be created and available.
67+
// +required
68+
VolumeRef KubernetesNameRef `json:"volumeRef"`
69+
70+
// device is the name of the device, such as `/dev/vdb`.
71+
// Omit for auto-assignment
72+
// +kubebuilder:validation:MaxLength:=255
73+
// +optional
74+
Device *string `json:"device,omitempty"`
75+
}
76+
77+
type ServerVolumeStatus struct {
78+
// id is the ID of a volume attached to the server.
79+
// +kubebuilder:validation:MaxLength:=1024
80+
// +optional
81+
ID string `json:"id,omitempty"`
82+
}
83+
6384
// ServerResourceSpec contains the desired state of a server
6485
type ServerResourceSpec struct {
6586
// name will be the name of the created resource. If not specified, the
@@ -92,6 +113,12 @@ type ServerResourceSpec struct {
92113
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ports is immutable"
93114
Ports []ServerPortSpec `json:"ports"`
94115

116+
// volumes is a list of volumes attached to the server.
117+
// +kubebuilder:validation:MaxItems:=32
118+
// +listType=atomic
119+
// +optional
120+
Volumes []ServerVolumeSpec `json:"volumes,omitempty"`
121+
95122
// serverGroupRef is a reference to a ServerGroup object. The server
96123
// will be created in the server group.
97124
// +optional
@@ -155,6 +182,12 @@ type ServerResourceStatus struct {
155182
// +optional
156183
ServerGroups []string `json:"serverGroups,omitempty"`
157184

185+
// volumes contains the volumes attached to the server.
186+
// +kubebuilder:validation:MaxItems:=32
187+
// +listType=atomic
188+
// +optional
189+
Volumes []ServerVolumeStatus `json:"volumes,omitempty"`
190+
158191
// tags is the list of tags on the resource.
159192
// +kubebuilder:validation:MaxItems:=32
160193
// +kubebuilder:validation:items:MaxLength=1024

api/v1alpha1/volume_types.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,27 @@ type VolumeFilter struct {
6969
Size *int32 `json:"size,omitempty"`
7070
}
7171

72+
type VolumeAttachmentStatus struct {
73+
// attachmentID represents the attachment UUID.
74+
// +kubebuilder:validation:MaxLength=1024
75+
// +optional
76+
AttachmentID string `json:"attachmentID"`
77+
78+
// serverID is the UUID of the server to which the volume is attached.
79+
// +kubebuilder:validation:MaxLength=1024
80+
// +optional
81+
ServerID string `json:"serverID"`
82+
83+
// device is the name of the device in the instance.
84+
// +kubebuilder:validation:MaxLength=1024
85+
// +optional
86+
Device string `json:"device"`
87+
88+
// attachedAt shows the date and time when the resource was attached. The date and time stamp format is ISO 8601.
89+
// +optional
90+
AttachedAt *metav1.Time `json:"attachedAt"`
91+
}
92+
7293
// VolumeResourceStatus represents the observed state of the resource.
7394
type VolumeResourceStatus struct {
7495
// name is a Human-readable name for the resource. Might not be unique.
@@ -95,8 +116,11 @@ type VolumeResourceStatus struct {
95116
// +optional
96117
AvailabilityZone string `json:"availabilityZone,omitempty"`
97118

98-
// Instances onto which the volume is attached.
99-
// Attachments []Attachment `json:"attachments"`
119+
// attachments is a list of attachments for the volume.
120+
// +kubebuilder:validation:MaxItems:=32
121+
// +listType=atomic
122+
// +optional
123+
Attachments []VolumeAttachmentStatus `json:"attachments"`
100124

101125
// volumeType is the name of associated the volume type.
102126
// +kubebuilder:validation:MaxLength=1024

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 73 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)