Skip to content

Commit

Permalink
move ResourceRequirement to another file
Browse files Browse the repository at this point in the history
  • Loading branch information
dongbeiqing91 committed Jan 19, 2024
1 parent 24a2a0e commit e303165
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 22 deletions.
36 changes: 36 additions & 0 deletions operator/v1/type_resourcerequirement.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package v1

import corev1 "k8s.io/api/core/v1"

type ResourceRequirementRequire 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"
)

func (k *Klusterlet) GetResourceRequirement() *ResourceRequirement {
return k.Spec.ResourceRequirement
}

func (cm *ClusterManager) GetResourceRequirement() *ResourceRequirement {
return cm.Spec.ResourceRequirement
}
22 changes: 0 additions & 22 deletions operator/v1/types_klusterlet.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package v1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit e303165

Please sign in to comment.