Skip to content

Commit

Permalink
move ResourceRequirement to a separate file
Browse files Browse the repository at this point in the history
Signed-off-by: Dong Beiqing <[email protected]>
  • Loading branch information
dongbeiqing91 committed Jan 22, 2024
1 parent 24a2a0e commit 25e246a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 31 deletions.
5 changes: 5 additions & 0 deletions operator/v1/funcs_clustermanager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package v1

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

func (k *Klusterlet) GetResourceRequirement() *ResourceRequirement {
return k.Spec.ResourceRequirement
}
28 changes: 28 additions & 0 deletions operator/v1/type_resourcerequirement.go
Original file line number Diff line number Diff line change
@@ -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"
)
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
9 changes: 0 additions & 9 deletions operator/v1/zz_generated.swagger_doc_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 25e246a

Please sign in to comment.