|
| 1 | +package v1alpha2 |
| 2 | + |
| 3 | +import ( |
| 4 | + corev1 "k8s.io/api/core/v1" |
| 5 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 6 | +) |
| 7 | + |
| 8 | +const ( |
| 9 | + // HRQLabelCleanup is added to resources created by HRQ (specifically the RQ |
| 10 | + // singletons) for easier cleanup later by a selector. |
| 11 | + HRQLabelCleanup = MetaGroup + "/hrq" |
| 12 | + |
| 13 | + // NonPropagateAnnotation is added to RQ singletons so that they are not |
| 14 | + // overwritten by ancestors. |
| 15 | + NonPropagateAnnotation = AnnotationPropagatePrefix + "/none" |
| 16 | + |
| 17 | + // EventCannotWriteResourceQuota is for events when the reconcilers cannot |
| 18 | + // write ResourceQuota from an HRQ. Usually it means the HRQ has invalid |
| 19 | + // resource quota types. The error message will point to the HRQ object. |
| 20 | + EventCannotWriteResourceQuota string = "CannotWriteResourceQuota" |
| 21 | +) |
| 22 | + |
| 23 | +// HierarchicalResourceQuotaSpec defines the desired hard limits to enforce for |
| 24 | +// a namespace and descendant namespaces |
| 25 | +type HierarchicalResourceQuotaSpec struct { |
| 26 | + // Hard is the set of desired hard limits for each named resource |
| 27 | + // +optional |
| 28 | + Hard corev1.ResourceList `json:"hard,omitempty"` |
| 29 | +} |
| 30 | + |
| 31 | +// HierarchicalResourceQuotaStatus defines the enforced hard limits and observed |
| 32 | +// use for a namespace and descendant namespaces |
| 33 | +type HierarchicalResourceQuotaStatus struct { |
| 34 | + // Hard is the set of enforced hard limits for each named resource |
| 35 | + // +optional |
| 36 | + Hard corev1.ResourceList `json:"hard,omitempty"` |
| 37 | + // Used is the current observed total usage of the resource in the namespace |
| 38 | + // and its descendant namespaces. |
| 39 | + // +optional |
| 40 | + Used corev1.ResourceList `json:"used,omitempty"` |
| 41 | +} |
| 42 | + |
| 43 | +// +kubebuilder:object:root=true |
| 44 | +// +kubebuilder:resource:path=hierarchicalresourcequotas,shortName=hrq,scope=Namespaced |
| 45 | + |
| 46 | +// HierarchicalResourceQuota sets aggregate quota restrictions enforced for a |
| 47 | +// namespace and descendant namespaces |
| 48 | +type HierarchicalResourceQuota struct { |
| 49 | + metav1.TypeMeta `json:",inline"` |
| 50 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 51 | + |
| 52 | + // Spec defines the desired quota |
| 53 | + Spec HierarchicalResourceQuotaSpec `json:"spec,omitempty"` |
| 54 | + // Status defines the actual enforced quota and its current usage |
| 55 | + Status HierarchicalResourceQuotaStatus `json:"status,omitempty"` |
| 56 | +} |
| 57 | + |
| 58 | +// +kubebuilder:object:root=true |
| 59 | + |
| 60 | +// HierarchicalResourceQuotaList contains a list of HierarchicalResourceQuota |
| 61 | +type HierarchicalResourceQuotaList struct { |
| 62 | + metav1.TypeMeta `json:",inline"` |
| 63 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 64 | + Items []HierarchicalResourceQuota `json:"items"` |
| 65 | +} |
| 66 | + |
| 67 | +func init() { |
| 68 | + SchemeBuilder.Register(&HierarchicalResourceQuota{}, &HierarchicalResourceQuotaList{}) |
| 69 | +} |
0 commit comments