Skip to content

Commit

Permalink
simplify nodeovercommitconfig, only support label selector value
Browse files Browse the repository at this point in the history
  • Loading branch information
WangZzzhe committed Sep 7, 2023
1 parent a5fac30 commit b51b7c9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ spec:
- jsonPath: .spec.resourceOvercommitRatioConfig
name: OVERCOMMITRATIO
type: string
- jsonPath: .spec.nodeOvercommitSelectorVal
name: SELECTOR
type: string
name: v1alpha1
schema:
openAPIV3Schema:
Expand All @@ -42,57 +45,11 @@ spec:
spec:
description: NodeOvercommitConfigSpec is a description of a NodeOvercommitConfig
properties:
nodeList:
description: NodeList decides whether to check and update nodes if
node in NodeList when Type equals to NodeList
items:
type: string
type: array
nodeSelector:
description: Selector decides whether to update Nodes if the Node
matches the selector when Type equals to LabelSelector
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
The requirements are ANDed.
items:
description: A label selector requirement is a selector that
contains values, a key, and an operator that relates the key
and values.
properties:
key:
description: key is the label key that the selector applies
to.
type: string
operator:
description: operator represents a key's relationship to
a set of values. Valid operators are In, NotIn, Exists
and DoesNotExist.
type: string
values:
description: values is an array of string values. If the
operator is In or NotIn, the values array must be non-empty.
If the operator is Exists or DoesNotExist, the values
array must be empty. This array is replaced during a strategic
merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator
is "In", and the values array contains only "value". The requirements
are ANDed.
type: object
type: object
nodeOvercommitSelectorVal:
description: NodeOvercommitSelectorVal is the value of node label
selector with key consts.NodeOvercommitSelectorKey, it decides whether
to update Nodes if the Node matches the selector 'consts.NodeOvercommitSelectorKey=NodeOvercommitSelectorVal'
type: string
resourceOvercommitRatioConfig:
additionalProperties:
type: string
Expand Down
10 changes: 4 additions & 6 deletions pkg/apis/overcommit/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ import (

// NodeOvercommitConfigSpec is a description of a NodeOvercommitConfig
type NodeOvercommitConfigSpec struct {
// Selector decides whether to update Nodes if the Node matches the selector when Type equals to LabelSelector
// NodeOvercommitSelectorVal is the value of node label selector with key consts.NodeOvercommitSelectorKey,
// it decides whether to update Nodes if the Node matches the selector 'consts.NodeOvercommitSelectorKey=NodeOvercommitSelectorVal'
// +optional
Selector *metav1.LabelSelector `json:"nodeSelector,omitempty"`

// NodeList decides whether to check and update nodes if node in NodeList when Type equals to NodeList
// +optional
NodeList []string `json:"nodeList,omitempty"`
NodeOvercommitSelectorVal string `json:"nodeOvercommitSelectorVal,omitempty"`

// ResourceOvercommitRatioConfig describes the resource overcommit ratio that needs to inject into Node.Annotations
// cpu,memory are supported.
Expand All @@ -49,6 +46,7 @@ type NodeOvercommitConfigStatus struct {
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,shortName=noc
// +kubebuilder:printcolumn:name="OVERCOMMITRATIO",type=string,JSONPath=".spec.resourceOvercommitRatioConfig"
// +kubebuilder:printcolumn:name="SELECTOR",type=string,JSONPath=".spec.nodeOvercommitSelectorVal"

// NodeOvercommitConfig is the Schema for the nodeovercommitconfigs API
type NodeOvercommitConfig struct {
Expand Down
15 changes: 2 additions & 13 deletions pkg/apis/overcommit/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 b51b7c9

Please sign in to comment.