Skip to content

Commit

Permalink
Merge pull request #63 from cheney-lin/dev/node_metric
Browse files Browse the repository at this point in the history
feat(kcnr): add node metric
  • Loading branch information
waynepeking348 authored Feb 21, 2024
2 parents edab146 + f5dfa7f commit dcfe569
Show file tree
Hide file tree
Showing 3 changed files with 327 additions and 0 deletions.
131 changes: 131 additions & 0 deletions config/crd/bases/node.katalyst.kubewharf.io_customnoderesources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,137 @@ spec:
- type
type: object
type: array
nodeMetricStatus:
description: NodeMetricStatus report node real-time metrics
properties:
groupMetric:
description: GroupMetric contains the metrics aggregated by QoS
level groups
items:
properties:
QoSLevel:
enum:
- reclaimed_cores
- shared_cores
- dedicated_cores
- system_cores
type: string
genericUsage:
description: GenericUsage contains the real-time resource
usage
properties:
cpu:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memory:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
numaUsage:
description: NUMAUsage contains the real-time resource usage
for each NUMA
items:
properties:
numaId:
type: integer
usage:
description: Usage contains the real-time resource
usage for this NUMA node
properties:
cpu:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memory:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
required:
- numaId
- usage
type: object
type: array
podList:
description: PodList indicates the pods belongs to this
qos group, in format of {namespace}/{name}. Pods that
have been scheduled but are not listed in the PodList
need to be estimated by the scheduler.
items:
type: string
type: array
required:
- QoSLevel
type: object
type: array
nodeMetric:
description: NodeMetric contains the metrics for this node.
properties:
genericUsage:
description: GenericUsage contains the real-time resource
usage
properties:
cpu:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memory:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
numaUsage:
description: NUMAUsage contains the real-time resource usage
for each NUMA
items:
properties:
numaId:
type: integer
usage:
description: Usage contains the real-time resource usage
for this NUMA node
properties:
cpu:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
memory:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
required:
- numaId
- usage
type: object
type: array
type: object
updateTime:
description: UpdateTime is the last time this NodeMetricStatus
was updated.
format: date-time
type: string
required:
- updateTime
type: object
resources:
description: Resources defines the numeric quantities in this node;
for instance reclaimed resources for this node
Expand Down
48 changes: 48 additions & 0 deletions pkg/apis/node/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ type CustomNodeResourceStatus struct {
// Conditions is an array of current observed cnr conditions.
// +optional
Conditions []CNRCondition `json:"conditions,omitempty"`

// NodeMetricStatus report node real-time metrics
// +optional
NodeMetricStatus *NodeMetricStatus `json:"nodeMetricStatus,omitempty"`
}

type TopologyPolicy string
Expand Down Expand Up @@ -278,3 +282,47 @@ type CustomNodeResourceList struct {
// items is the list of CNRs
Items []CustomNodeResource `json:"items"`
}

// NodeMetricStatus defines the observed state of NodeMetric
type NodeMetricStatus struct {
// UpdateTime is the last time this NodeMetricStatus was updated.
UpdateTime metav1.Time `json:"updateTime"`

// NodeMetric contains the metrics for this node.
NodeMetric *NodeMetricInfo `json:"nodeMetric,omitempty"`

// GroupMetric contains the metrics aggregated by QoS level groups
GroupMetric []GroupMetricInfo `json:"groupMetric,omitempty"`
}

type ResourceMetric struct {
CPU *resource.Quantity `json:"cpu,omitempty"`
Memory *resource.Quantity `json:"memory,omitempty"`
}

type ResourceUsage struct {
// NUMAUsage contains the real-time resource usage for each NUMA
NUMAUsage []NUMAMetricInfo `json:"numaUsage,omitempty"`

// GenericUsage contains the real-time resource usage
GenericUsage *ResourceMetric `json:"genericUsage,omitempty"`
}

type GroupMetricInfo struct {
// +kubebuilder:validation:Enum=reclaimed_cores;shared_cores;dedicated_cores;system_cores
QoSLevel string `json:"QoSLevel"`
ResourceUsage `json:",inline"`
// PodList indicates the pods belongs to this qos group, in format of {namespace}/{name}.
// Pods that have been scheduled but are not listed in the PodList need to be estimated by the scheduler.
PodList []string `json:"podList,omitempty"`
}

type NodeMetricInfo struct {
ResourceUsage `json:",inline"`
}

type NUMAMetricInfo struct {
NUMAId int `json:"numaId"`
// Usage contains the real-time resource usage for this NUMA node
Usage *ResourceMetric `json:"usage"`
}
148 changes: 148 additions & 0 deletions pkg/apis/node/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 dcfe569

Please sign in to comment.