diff --git a/config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml b/config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml index 8e23101..aba5787 100644 --- a/config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml +++ b/config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml @@ -24,6 +24,9 @@ spec: - jsonPath: .spec.nodeLabelSelector name: SELECTOR type: string + - jsonPath: .spec.priority + name: PRIORITY + type: string - jsonPath: .spec.ephemeralSelector.nodeNames name: NODES type: string @@ -296,7 +299,8 @@ spec: pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true description: MinReclaimedResourceForAllocate is a resource - reserved for reclaimed_cores pods. + reserved for reclaimed_cores pods,these resources will not + be used by shared_cores pods. type: object minReclaimedResourceForReport: additionalProperties: @@ -337,7 +341,7 @@ spec: type: object type: object ephemeralSelector: - description: EphemeralSelector is used to indicate the + description: EphemeralSelector is a selector for temporary use only properties: lastDuration: description: define the duration this configuration will last @@ -351,12 +355,18 @@ spec: type: array type: object nodeLabelSelector: - description: NodeLabelSelector select nodes to apply these configurations - if spec.labelKey no set, NodeLabelSelector must be empty, the label - selector must only include KatalystCustomConfig.spec .nodeLabelSelectorKey, - otherwise it will not be synced This field will be immutable after - it is initially set. + description: NodeLabelSelector select nodes to apply these configurations, + the priority and node label selector must be matched according to + KatalystCustomConfig.spec.nodeLabelSelectorAllowedKeyList, otherwise + it will not be synced. type: string + priority: + description: Priority is used by one node matched by NodeLabelSelector + of more than one configuration, and the higher priority will be + considered. The priority only be supported when NodeLabelSelector + set + format: int32 + type: integer revisionHistoryLimit: default: 3 description: RevisionHistoryLimit is the maximum number of revisions diff --git a/config/crd/bases/config.katalyst.kubewharf.io_katalystcustomconfigs.yaml b/config/crd/bases/config.katalyst.kubewharf.io_katalystcustomconfigs.yaml index de87dcf..c4ef365 100644 --- a/config/crd/bases/config.katalyst.kubewharf.io_katalystcustomconfigs.yaml +++ b/config/crd/bases/config.katalyst.kubewharf.io_katalystcustomconfigs.yaml @@ -27,9 +27,6 @@ spec: - jsonPath: .spec.targetType.version name: VERSION type: string - - jsonPath: .spec.nodeLabelSelectorKey - name: KEY - type: string - jsonPath: .metadata.generation name: GENERATION type: integer @@ -74,10 +71,31 @@ spec: description: whether disable revisionHistory for the KatalystCustomConfig resource type: boolean - nodeLabelSelectorKey: - description: key of node label to select which nodes will be effected - by the KatalystCustomConfig resource - type: string + nodeLabelSelectorAllowedKeyList: + description: the keys list allowed in node selector to select which + nodes will be effected by the KatalystCustomConfig resource, and + the priority will be used when one node match two KatalystCustomConfig + resource at the same time, the higher priority one will be considered. + If not set, node label selector is not allowed to use. + items: + description: PriorityNodeLabelSelectorAllowedKeyList defines the + priority and its allowed key list + properties: + keyList: + description: KeyList is allowed to use in node selector in the + Priority + items: + type: string + type: array + priority: + description: Priority is the priority of configurations + format: int32 + type: integer + required: + - keyList + - priority + type: object + type: array targetType: description: the GVR of target config type properties: diff --git a/pkg/apis/config/v1alpha1/adminqos.go b/pkg/apis/config/v1alpha1/adminqos.go index 69d06ce..2d40ebe 100644 --- a/pkg/apis/config/v1alpha1/adminqos.go +++ b/pkg/apis/config/v1alpha1/adminqos.go @@ -27,6 +27,7 @@ import ( // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="AGE",type=date,JSONPath=.metadata.creationTimestamp // +kubebuilder:printcolumn:name="SELECTOR",type=string,JSONPath=".spec.nodeLabelSelector" +// +kubebuilder:printcolumn:name="PRIORITY",type=string,JSONPath=".spec.priority" // +kubebuilder:printcolumn:name="NODES",type=string,JSONPath=".spec.ephemeralSelector.nodeNames" // +kubebuilder:printcolumn:name="DURATION",type=string,JSONPath=".spec.ephemeralSelector.lastDuration" // +kubebuilder:printcolumn:name="VALID",type=string,JSONPath=".status.conditions[?(@.type==\"Valid\")].status" diff --git a/pkg/apis/config/v1alpha1/generic.go b/pkg/apis/config/v1alpha1/generic.go index 0e91629..be338c8 100644 --- a/pkg/apis/config/v1alpha1/generic.go +++ b/pkg/apis/config/v1alpha1/generic.go @@ -29,15 +29,20 @@ type GenericConfigSpec struct { // +kubebuilder:default:=3 RevisionHistoryLimit int64 `json:"revisionHistoryLimit,omitempty"` - // NodeLabelSelector select nodes to apply these configurations - // if spec.labelKey no set, NodeLabelSelector must be empty, the - // label selector must only include KatalystCustomConfig.spec - // .nodeLabelSelectorKey, otherwise it will not be synced - // This field will be immutable after it is initially set. + // NodeLabelSelector select nodes to apply these configurations, + // the priority and node label selector must be matched according + // to KatalystCustomConfig.spec.nodeLabelSelectorAllowedKeyList, + // otherwise it will not be synced. // +optional NodeLabelSelector string `json:"nodeLabelSelector,omitempty"` - // EphemeralSelector is used to indicate the + // Priority is used by one node matched by NodeLabelSelector of more + // than one configuration, and the higher priority will be considered. + // The priority only be supported when NodeLabelSelector set + // +optional + Priority int32 `json:"priority,omitempty"` + + // EphemeralSelector is a selector for temporary use only // +optional EphemeralSelector EphemeralSelector `json:"ephemeralSelector,omitempty"` } diff --git a/pkg/apis/config/v1alpha1/types.go b/pkg/apis/config/v1alpha1/types.go index c9ccdca..6d64961 100644 --- a/pkg/apis/config/v1alpha1/types.go +++ b/pkg/apis/config/v1alpha1/types.go @@ -28,7 +28,6 @@ import ( // +kubebuilder:printcolumn:name="GROUP",type="string",JSONPath=".spec.targetType.group" // +kubebuilder:printcolumn:name="RESOURCE",type="string",JSONPath=".spec.targetType.resource" // +kubebuilder:printcolumn:name="VERSION",type="string",JSONPath=".spec.targetType.version" -// +kubebuilder:printcolumn:name="KEY",type="string",JSONPath=".spec.nodeLabelSelectorKey" // +kubebuilder:printcolumn:name="GENERATION",type="integer",JSONPath=".metadata.generation" // +kubebuilder:printcolumn:name="OBSERVED",type="integer",JSONPath=".status.observedGeneration" // +kubebuilder:printcolumn:name="INVALID",type="string",JSONPath=".status.invalidTargetConfigList" @@ -53,9 +52,21 @@ type KatalystCustomConfigSpec struct { // +kubebuilder:default:=true // +optional DisableRevisionHistory bool `json:"disableRevisionHistory,omitempty"` - // key of node label to select which nodes will be effected by the KatalystCustomConfig resource + // the keys list allowed in node selector to select which nodes will be effected by the KatalystCustomConfig resource, + // and the priority will be used when one node match two KatalystCustomConfig resource at the same time, the higher + // priority one will be considered. If not set, node label selector is not allowed to use. + // +patchMergeKey=priority + // +patchStrategy=merge // +optional - NodeLabelSelectorKey string `json:"nodeLabelSelectorKey,omitempty"` + NodeLabelSelectorAllowedKeyList []PriorityNodeLabelSelectorAllowedKeyList `json:"nodeLabelSelectorAllowedKeyList,omitempty"` +} + +// PriorityNodeLabelSelectorAllowedKeyList defines the priority and its allowed key list +type PriorityNodeLabelSelectorAllowedKeyList struct { + // Priority is the priority of configurations + Priority int32 `json:"priority"` + // KeyList is allowed to use in node selector in the Priority + KeyList []string `json:"keyList"` } // KatalystCustomConfigStatus defines the observed state of KatalystCustomConfig diff --git a/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go index 06710f8..c576499 100644 --- a/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go @@ -488,7 +488,7 @@ func (in *KatalystCustomConfig) DeepCopyInto(out *KatalystCustomConfig) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec + in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) return } @@ -565,6 +565,13 @@ func (in *KatalystCustomConfigList) DeepCopyObject() runtime.Object { func (in *KatalystCustomConfigSpec) DeepCopyInto(out *KatalystCustomConfigSpec) { *out = *in out.TargetType = in.TargetType + if in.NodeLabelSelectorAllowedKeyList != nil { + in, out := &in.NodeLabelSelectorAllowedKeyList, &out.NodeLabelSelectorAllowedKeyList + *out = make([]PriorityNodeLabelSelectorAllowedKeyList, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } @@ -729,6 +736,27 @@ func (in *MemoryPressureEvictionConfig) DeepCopy() *MemoryPressureEvictionConfig return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PriorityNodeLabelSelectorAllowedKeyList) DeepCopyInto(out *PriorityNodeLabelSelectorAllowedKeyList) { + *out = *in + if in.KeyList != nil { + in, out := &in.KeyList, &out.KeyList + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PriorityNodeLabelSelectorAllowedKeyList. +func (in *PriorityNodeLabelSelectorAllowedKeyList) DeepCopy() *PriorityNodeLabelSelectorAllowedKeyList { + if in == nil { + return nil + } + out := new(PriorityNodeLabelSelectorAllowedKeyList) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ReclaimedResourceConfig) DeepCopyInto(out *ReclaimedResourceConfig) { *out = *in