diff --git a/operator/v1/funcs_clustermanager.go b/operator/v1/funcs_clustermanager.go new file mode 100644 index 000000000..8ed923b8c --- /dev/null +++ b/operator/v1/funcs_clustermanager.go @@ -0,0 +1,5 @@ +package v1 + +func (cm *ClusterManager) GetResourceRequirement() *ResourceRequirement { + return cm.Spec.ResourceRequirement +} diff --git a/operator/v1/funcs_klusterlet.go b/operator/v1/funcs_klusterlet.go new file mode 100644 index 000000000..3bd56472f --- /dev/null +++ b/operator/v1/funcs_klusterlet.go @@ -0,0 +1,5 @@ +package v1 + +func (k *Klusterlet) GetResourceRequirement() *ResourceRequirement { + return k.Spec.ResourceRequirement +} diff --git a/operator/v1/type_resourcerequirement.go b/operator/v1/type_resourcerequirement.go new file mode 100644 index 000000000..e2f9ba6b3 --- /dev/null +++ b/operator/v1/type_resourcerequirement.go @@ -0,0 +1,28 @@ +package v1 + +import corev1 "k8s.io/api/core/v1" + +type ResourceRequirementAcquirer interface { + GetResourceRequirement() *ResourceRequirement +} + +// ResourceRequirement allow user override the default pod QoS classes +type ResourceRequirement struct { + // +kubebuilder:validation:Enum=Default;BestEffort;ResourceRequirement + // +kubebuilder:default:=Default + Type ResourceQosClass `json:"type"` + // ResourceRequirements defines resource requests and limits when Type is ResourceQosClassResourceRequirement + // +optional + ResourceRequirements *corev1.ResourceRequirements `json:"resourceRequirements,omitempty"` +} + +type ResourceQosClass string + +const ( + // Default use resource setting in the template file (with requests but no limits in the resources) + ResourceQosClassDefault ResourceQosClass = "Default" + // If all containers in the pod don't set resource request and limits, the pod is treated as BestEffort. + ResourceQosClassBestEffort ResourceQosClass = "BestEffort" + // Configurable resource requirements with requests and limits + ResourceQosClassResourceRequirement ResourceQosClass = "ResourceRequirement" +) diff --git a/operator/v1/types_klusterlet.go b/operator/v1/types_klusterlet.go index 28bf07c04..bef65984f 100644 --- a/operator/v1/types_klusterlet.go +++ b/operator/v1/types_klusterlet.go @@ -1,7 +1,6 @@ package v1 import ( - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -96,27 +95,6 @@ type KlusterletSpec struct { ResourceRequirement *ResourceRequirement `json:"resourceRequirement,omitempty"` } -type ResourceQosClass string - -const ( - // Default use resource setting in the template file (with requests but no limits in the resources) - ResourceQosClassDefault ResourceQosClass = "Default" - // If all containers in the pod don't set resource request and limits, the pod is treated as BestEffort. - ResourceQosClassBestEffort ResourceQosClass = "BestEffort" - // Configurable resource requirements with requests and limits - ResourceQosClassResourceRequirement ResourceQosClass = "ResourceRequirement" -) - -// ResourceRequirement allow user override the default pod QoS classes -type ResourceRequirement struct { - // +kubebuilder:validation:Enum=Default;BestEffort;ResourceRequirement - // +kubebuilder:default:=Default - Type ResourceQosClass `json:"type"` - // ResourceRequirements defines resource requests and limits when Type is ResourceQosClassResourceRequirement - // +optional - ResourceRequirements *corev1.ResourceRequirements `json:"resourceRequirements,omitempty"` -} - // ServerURL represents the apiserver url and ca bundle that is accessible externally type ServerURL struct { // URL is the url of apiserver endpoint of the managed cluster. diff --git a/operator/v1/zz_generated.swagger_doc_generated.go b/operator/v1/zz_generated.swagger_doc_generated.go index 03dd6add1..8d8a14f20 100644 --- a/operator/v1/zz_generated.swagger_doc_generated.go +++ b/operator/v1/zz_generated.swagger_doc_generated.go @@ -245,15 +245,6 @@ func (RegistrationConfiguration) SwaggerDoc() map[string]string { return map_RegistrationConfiguration } -var map_ResourceRequirement = map[string]string{ - "": "ResourceRequirement allow user override the default pod QoS classes", - "resourceRequirements": "ResourceRequirements defines resource requests and limits when Type is ResourceQosClassResourceRequirement", -} - -func (ResourceRequirement) SwaggerDoc() map[string]string { - return map_ResourceRequirement -} - var map_ServerURL = map[string]string{ "": "ServerURL represents the apiserver url and ca bundle that is accessible externally", "url": "URL is the url of apiserver endpoint of the managed cluster.",