Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apis: add HostApplications for out-of-band application #1508

Merged
merged 1 commit into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="$(LICENSE_HEADER_GO)" paths="./apis/..."
$(CONTROLLER_GEN) object:headerFile="$(LICENSE_HEADER_GO)" paths="./pkg/slo-controller/config/..."
@hack/update-codegen.sh

.PHONY: fmt
Expand Down
50 changes: 50 additions & 0 deletions apis/configuration/slo_controller_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
ResourceQOSConfigKey = "resource-qos-config"
CPUBurstConfigKey = "cpu-burst-config"
SystemConfigKey = "system-config"
HostApplicationConfigKey = "host-application-config"
)

// +k8s:deepcopy-gen=true
Expand Down Expand Up @@ -88,6 +89,18 @@ type SystemCfg struct {
NodeStrategies []NodeSystemStrategy `json:"nodeStrategies,omitempty" validate:"dive"`
}

// +k8s:deepcopy-gen=true
type NodeHostApplicationCfg struct {
NodeCfgProfile `json:",inline"`
Applications []slov1alpha1.HostApplicationSpec `json:"applications,omitempty"`
}

// +k8s:deepcopy-gen=true
type HostApplicationCfg struct {
Applications []slov1alpha1.HostApplicationSpec `json:"applications,omitempty"`
NodeConfigs []NodeHostApplicationCfg `json:"nodeConfigs,omitempty"`
}

// +k8s:deepcopy-gen=true
type ResourceQOSCfg struct {
ClusterStrategy *slov1alpha1.ResourceQOSStrategy `json:"clusterStrategy,omitempty"`
Expand Down Expand Up @@ -455,6 +468,43 @@ data:
}
]
}
host-application-config: |
{
"applications": [
{
"name": "nginx",
"priority": "koord-prod",
"qos": "LS",
"cgroupPath": {
"base": "CgroupRoot",
"parentDir": "host-latency-sensitive/",
"relativePath": "nginx/",
}
}
],
"nodeConfigs": [
{
"name": "colocation-pool",
"nodeSelector": {
"matchLabels": {
"node-pool": "colocation"
}
},
"applications": [
{
"name": "nginx",
"priority": "koord-prod",
"qos": "LS",
"cgroupPath": {
"base": "CgroupRoot",
"parentDir": "host-latency-sensitive/",
"relativePath": "nginx/",
}
}
]
}
]
}
kind: ConfigMap
metadata:
annotations:
Expand Down
52 changes: 52 additions & 0 deletions apis/configuration/zz_generated.deepcopy.go

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

61 changes: 61 additions & 0 deletions apis/slo/v1alpha1/host_application.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright 2022 The Koordinator Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"github.com/koordinator-sh/koordinator/apis/extension"
)

// HostApplicationSpec describes the QoS management for out-out-band applications on node
type HostApplicationSpec struct {
Name string `json:"name,omitempty"`
// Priority class of the application
Priority extension.PriorityClass `json:"priority,omitempty"`
// QoS class of the application
QoS extension.QoSClass `json:"qos,omitempty"`
// Optional, defines the host cgroup configuration, use default if not specified according to priority and qos
CgroupPath *CgroupPath `json:"cgroupPath,omitempty"`
// QoS Strategy of host application
Strategy *HostApplicationStrategy `json:"strategy,omitempty"`
}

type HostApplicationStrategy struct {
}

// CgroupPath decribes the cgroup path for out-of-band applications
type CgroupPath struct {
// cgroup base dir, the format is various across cgroup drivers
Base CgroupBaseType `json:"base,omitempty"`
// cgroup parent path under base dir
ParentDir string `json:"parentDir,omitempty"`
// cgroup relative path under parent dir
RelativePath string `json:"relativePath,omitempty"`
}

// CgroupBaseType defines the cgroup base dir for HostCgroup
type CgroupBaseType string

const (
// CgroupBaseTypeRoot is the root dir of cgroup fs on node, e.g. /sys/fs/cgroup/cpu/
CgroupBaseTypeRoot CgroupBaseType = "CgroupRoot"
// CgroupBaseTypeRoot is the cgroup dir for k8s pods, e.g. /sys/fs/cgroup/cpu/kubepods/
CgroupBaseTypeKubepods CgroupBaseType = "Kubepods"
// CgroupBaseTypeRoot is the cgroup dir for k8s burstable pods, e.g. /sys/fs/cgroup/cpu/kubepods/burstable/
CgroupBaseTypeKubeBurstable CgroupBaseType = "KubepodsBurstable"
// CgroupBaseTypeRoot is the cgroup dir for k8s besteffort pods, e.g. /sys/fs/cgroup/cpu/kubepods/besteffort/
CgroupBaseTypeKubeBesteffort CgroupBaseType = "KubepodsBesteffort"
)
2 changes: 2 additions & 0 deletions apis/slo/v1alpha1/nodeslo_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ type NodeSLOSpec struct {
SystemStrategy *SystemStrategy `json:"systemStrategy,omitempty"`
// Third party extensions for NodeSLO
Extensions *ExtensionsMap `json:"extensions,omitempty"`
// QoS management for out-of-band applications
HostApplications []HostApplicationSpec `json:"hostApplications,omitempty"`
}

// NodeSLOStatus defines the observed state of NodeSLO
Expand Down
62 changes: 62 additions & 0 deletions apis/slo/v1alpha1/zz_generated.deepcopy.go

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

34 changes: 34 additions & 0 deletions config/crd/bases/slo.koordinator.sh_nodeslos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,40 @@ spec:
description: Third party extensions for NodeSLO
type: object
x-kubernetes-preserve-unknown-fields: true
hostApplications:
description: QoS management for out-of-band applications
items:
description: HostApplicationSpec describes the QoS management for
out-out-band applications on node
properties:
cgroupPath:
description: Optional, defines the host cgroup configuration,
use default if not specified according to priority and qos
properties:
base:
description: cgroup base dir, the format is various across
cgroup drivers
type: string
parentDir:
description: cgroup parent path under base dir
type: string
relativePath:
description: cgroup relative path under parent dir
type: string
type: object
name:
type: string
priority:
description: Priority class of the application
type: string
qos:
description: QoS class of the application
type: string
strategy:
description: QoS Strategy of host application
type: object
type: object
type: array
resourceQOSStrategy:
description: QoS config strategy for pods of different qos-class
properties:
Expand Down
2 changes: 1 addition & 1 deletion pkg/features/koordlet_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ var (

// IsFeatureDisabled returns whether the featuregate is disabled by nodeSLO config
func IsFeatureDisabled(nodeSLO *slov1alpha1.NodeSLO, feature featuregate.Feature) (bool, error) {
if nodeSLO == nil || nodeSLO.Spec == (slov1alpha1.NodeSLOSpec{}) {
if nodeSLO == nil {
return true, fmt.Errorf("cannot parse feature config for invalid nodeSLO %v", nodeSLO)
}

Expand Down