Skip to content

Commit

Permalink
kcc support priority and its allowed selector key list
Browse files Browse the repository at this point in the history
  • Loading branch information
luomingmeng committed Aug 7, 2023
1 parent 7cb845b commit 588be3f
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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, any key is allowed, but only priority 0 can be used.
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:
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/config/v1alpha1/adminqos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 11 additions & 6 deletions pkg/apis/config/v1alpha1/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
17 changes: 14 additions & 3 deletions pkg/apis/config/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
30 changes: 29 additions & 1 deletion pkg/apis/config/v1alpha1/zz_generated.deepcopy.go

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

0 comments on commit 588be3f

Please sign in to comment.