k8c.io/api/v3@v3.0.0-20230904060738-b0a93889c0b6/pkg/apis/kubermatic/v1/ee.resource_quota.go (about) 1 /* 2 Copyright 2023 The Kubermatic Kubernetes Platform contributors. 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 v1 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 ) 22 23 const ( 24 ResourceQuotaSubjectNameLabelKey = "subject-name" 25 ResourceQuotaSubjectKindLabelKey = "subject-kind" 26 ) 27 28 // +kubebuilder:validation:Enum=project 29 30 type ResourceQuotaSubjectName string 31 32 const ( 33 ResourceQuotaSubjectProject ResourceQuotaSubjectName = "project" 34 ) 35 36 // +genclient 37 // +kubebuilder:resource:scope=Cluster 38 // +kubebuilder:resource:categories=kkpee 39 // +kubebuilder:object:generate=true 40 // +kubebuilder:object:root=true 41 // +kubebuilder:subresource:status 42 // +kubebuilder:printcolumn:JSONPath=".spec.cluster.name",name="Cluster",type="string" 43 // +kubebuilder:printcolumn:JSONPath=".spec.subject.name",name="Subject Name",type="string" 44 // +kubebuilder:printcolumn:JSONPath=".spec.subject.kind",name="Subject Kind",type="string" 45 // +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name="Age",type="date" 46 47 // ResourceQuota specifies the amount of cluster resources a project can use. 48 // 49 // Note that this resource is part of a KKP Enterprise feature and is not used in the Community Edition. 50 type ResourceQuota struct { 51 metav1.TypeMeta `json:",inline"` 52 metav1.ObjectMeta `json:"metadata,omitempty"` 53 54 Spec ResourceQuotaSpec `json:"spec,omitempty"` 55 Status ResourceQuotaStatus `json:"status,omitempty"` 56 } 57 58 // ResourceQuotaSpec describes the desired state of a resource quota. 59 type ResourceQuotaSpec struct { 60 // Subject specifies to which entity the quota applies to. 61 Subject ResourceQuotaSubject `json:"subject"` 62 // Quota specifies the current maximum allowed usage of resources. 63 Quota ResourceDetails `json:"quota"` 64 } 65 66 // ResourceQuotaStatus describes the current state of a resource quota. 67 type ResourceQuotaStatus struct { 68 // GlobalUsage is holds the current usage of resources for all seeds. 69 GlobalUsage *ResourceDetails `json:"globalUsage,omitempty"` 70 // LocalUsage is holds the current usage of resources for the local seed. 71 LocalUsage *ResourceDetails `json:"localUsage,omitempty"` 72 } 73 74 // ResourceQuotaSubject describes the entity to which the quota applies to. 75 type ResourceQuotaSubject struct { 76 // Name of the quota subject. 77 Name string `json:"name"` 78 79 // +kubebuilder:default=project 80 81 // Kind of the quota subject. 82 Kind ResourceQuotaSubjectName `json:"kind"` 83 } 84 85 // +kubebuilder:object:generate=true 86 // +kubebuilder:object:root=true 87 88 // ResourceQuotaList is a collection of resource quotas. 89 type ResourceQuotaList struct { 90 metav1.TypeMeta `json:",inline"` 91 metav1.ListMeta `json:"metadata,omitempty"` 92 93 Items []ResourceQuota `json:"items"` 94 }