|
| 1 | +/* |
| 2 | +Copyright 2025 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha2 |
| 18 | + |
| 19 | +import ( |
| 20 | + "k8s.io/apimachinery/pkg/api/resource" |
| 21 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 22 | +) |
| 23 | + |
| 24 | +// StoragePolicyReservationSpec defines the desired state of StoragePolicyReservation |
| 25 | +type StoragePolicyReservationSpec struct { |
| 26 | + // +kubebuilder:validation:Required |
| 27 | + Requested []Requested `json:"requested"` |
| 28 | +} |
| 29 | + |
| 30 | +// Requested defines a storage reservation request for a given object |
| 31 | +type Requested struct { |
| 32 | + // APIGroup is the group for the resource being referenced. |
| 33 | + // If APIGroup is not specified, the specified Kind must be in the core API group. |
| 34 | + // For any other third-party types, APIGroup is required. |
| 35 | + // +optional |
| 36 | + APIGroup *string `json:"apiGroup,omitempty"` |
| 37 | + // Kind of the requested storage object. |
| 38 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
| 39 | + Kind string `json:"kind"` |
| 40 | + // Name of the requested storage object such as a VM service VM API object. |
| 41 | + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names |
| 42 | + Name string `json:"name"` |
| 43 | + // +listType=map |
| 44 | + // +listMapKey=storageClassName |
| 45 | + // ReservationRequests define request for storage quota associated with a StorageClass |
| 46 | + ReservationRequests []ReservationRequest `json:"reservationRequests"` |
| 47 | +} |
| 48 | + |
| 49 | +// ReservationRequest defines request for storage quota associated with a StorageClass |
| 50 | +type ReservationRequest struct { |
| 51 | + // Name of the Kubernetes StorageClass |
| 52 | + StorageClassName string `json:"storageClassName"` |
| 53 | + // Requested capacity for a storage resource to be provisioned at a later time |
| 54 | + Request *resource.Quantity `json:"request,omitempty"` |
| 55 | +} |
| 56 | + |
| 57 | +// StoragePolicyReservationStatus defines the observed state of StoragePolicyReservation |
| 58 | +type StoragePolicyReservationStatus struct { |
| 59 | + Approved []StorageObject `json:"approved,omitempty"` |
| 60 | + Denied []StorageObject `json:"denied,omitempty"` |
| 61 | +} |
| 62 | + |
| 63 | +// StorageObject defines a storage reservation for a given object |
| 64 | +type StorageObject struct { |
| 65 | + // APIGroup is the group for the resource being referenced. |
| 66 | + // If APIGroup is not specified, the specified Kind must be in the core API group. |
| 67 | + // For any other third-party types, APIGroup is required. |
| 68 | + // +optional |
| 69 | + APIGroup *string `json:"apiGroup,omitempty"` |
| 70 | + // Kind of the requested storage object. |
| 71 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds |
| 72 | + Kind string `json:"kind"` |
| 73 | + // Name of the requested storage object. |
| 74 | + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names |
| 75 | + Name string `json:"name"` |
| 76 | + // Name of the Kubernetes StorageClass |
| 77 | + StorageClassName string `json:"storageClassName"` |
| 78 | + // Requested capacity for a storage resource being provisioned |
| 79 | + Request *resource.Quantity `json:"request,omitempty"` |
| 80 | + // Indicates the reason why the reservation for an object is being denied |
| 81 | + // +optional |
| 82 | + Reason *string `json:"reason,omitempty"` |
| 83 | +} |
| 84 | + |
| 85 | +//+kubebuilder:object:root=true |
| 86 | +//+kubebuilder:subresource:status |
| 87 | +//+kubebuilder:storageversion |
| 88 | + |
| 89 | +// StoragePolicyReservation is the Schema for the storagepolicyreservations API |
| 90 | +type StoragePolicyReservation struct { |
| 91 | + metav1.TypeMeta `json:",inline"` |
| 92 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 93 | + |
| 94 | + Spec StoragePolicyReservationSpec `json:"spec"` |
| 95 | + Status StoragePolicyReservationStatus `json:"status,omitempty"` |
| 96 | +} |
| 97 | + |
| 98 | +//+kubebuilder:object:root=true |
| 99 | + |
| 100 | +// StoragePolicyReservationList contains a list of StoragePolicyReservation |
| 101 | +type StoragePolicyReservationList struct { |
| 102 | + metav1.TypeMeta `json:",inline"` |
| 103 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 104 | + Items []StoragePolicyReservation `json:"items"` |
| 105 | +} |
0 commit comments