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

OCPBUGS-23900: config.openshift.io/v1/scheduler: allow profile customizations for DRA #1738

Merged
merged 8 commits into from Feb 8, 2024
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
@@ -0,0 +1,130 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.openshift.io: https://github.com/openshift/api/pull/470
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
include.release.openshift.io/single-node-developer: "true"
release.openshift.io/feature-set: CustomNoUpgrade
name: schedulers.config.openshift.io
spec:
group: config.openshift.io
names:
kind: Scheduler
listKind: SchedulerList
plural: schedulers
singular: scheduler
scope: Cluster
versions:
- name: v1
schema:
openAPIV3Schema:
description: "Scheduler holds cluster-wide config information to run the Kubernetes
Scheduler and influence its placement decisions. The canonical name for
this config is `cluster`. \n Compatibility level 1: Stable within a major
release for a minimum of 12 months or 3 minor releases (whichever is longer)."
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: spec holds user settable values for configuration
properties:
defaultNodeSelector:
description: 'defaultNodeSelector helps set the cluster-wide default
node selector to restrict pod placement to specific nodes. This
is applied to the pods created in all namespaces and creates an
intersection with any existing nodeSelectors already set on a pod,
additionally constraining that pod''s selector. For example, defaultNodeSelector:
"type=user-node,region=east" would set nodeSelector field in pod
spec to "type=user-node,region=east" to all pods created in all
namespaces. Namespaces having project-wide node selectors won''t
be impacted even if this field is set. This adds an annotation section
to the namespace. For example, if a new namespace is created with
node-selector=''type=user-node,region=east'', the annotation openshift.io/node-selector:
type=user-node,region=east gets added to the project. When the openshift.io/node-selector
annotation is set on the project the value is used in preference
to the value we are setting for defaultNodeSelector field. For instance,
openshift.io/node-selector: "type=user-node,region=west" means that
the default of "type=user-node,region=east" set in defaultNodeSelector
would not be applied.'
type: string
mastersSchedulable:
description: 'MastersSchedulable allows masters nodes to be schedulable.
When this flag is turned on, all the master nodes in the cluster
will be made schedulable, so that workload pods can run on them.
The default value for this field is false, meaning none of the master
nodes are schedulable. Important Note: Once the workload pods start
running on the master nodes, extreme care must be taken to ensure
that cluster-critical control plane components are not impacted.
Please turn on this field after doing due diligence.'
type: boolean
policy:
description: 'DEPRECATED: the scheduler Policy API has been deprecated
and will be removed in a future release. policy is a reference to
a ConfigMap containing scheduler policy which has user specified
predicates and priorities. If this ConfigMap is not available scheduler
will default to use DefaultAlgorithmProvider. The namespace for
this configmap is openshift-config.'
properties:
name:
description: name is the metadata.name of the referenced config
map
type: string
required:
- name
type: object
profile:
description: "profile sets which scheduling profile should be set
in order to configure scheduling decisions for new pods. \n Valid
values are \"LowNodeUtilization\", \"HighNodeUtilization\", \"NoScoring\"
Defaults to \"LowNodeUtilization\""
enum:
- ""
- LowNodeUtilization
- HighNodeUtilization
- NoScoring
type: string
profileCustomizations:
description: profileCustomizations contains configuration for modifying
the default behavior of existing scheduler profiles.
properties:
dynamicResourceAllocation:
description: dynamicResourceAllocation allows to enable or disable
dynamic resource allocation within the scheduler. Dynamic resource
allocation is an API for requesting and sharing resources between
pods and containers inside a pod. Third-party resource drivers
are responsible for tracking and allocating resources. Different
kinds of resources support arbitrary parameters for defining
requirements and initialization. Valid values are Enabled, Disabled
and omitted. When omitted, this means no opinion and the platform
is left to choose a reasonable default, which is subject to
change over time. The current default is Disabled.
enum:
- ""
- Enabled
- Disabled
type: string
type: object
type: object
status:
description: status holds observed values from the cluster. They may not
be overridden.
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
Expand Up @@ -6,6 +6,7 @@ metadata:
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
include.release.openshift.io/single-node-developer: "true"
release.openshift.io/feature-set: Default
name: schedulers.config.openshift.io
spec:
group: config.openshift.io
Expand Down
@@ -0,0 +1,130 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.openshift.io: https://github.com/openshift/api/pull/470
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
include.release.openshift.io/single-node-developer: "true"
release.openshift.io/feature-set: TechPreviewNoUpgrade
name: schedulers.config.openshift.io
spec:
group: config.openshift.io
names:
kind: Scheduler
listKind: SchedulerList
plural: schedulers
singular: scheduler
scope: Cluster
versions:
- name: v1
schema:
openAPIV3Schema:
description: "Scheduler holds cluster-wide config information to run the Kubernetes
Scheduler and influence its placement decisions. The canonical name for
this config is `cluster`. \n Compatibility level 1: Stable within a major
release for a minimum of 12 months or 3 minor releases (whichever is longer)."
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: spec holds user settable values for configuration
properties:
defaultNodeSelector:
description: 'defaultNodeSelector helps set the cluster-wide default
node selector to restrict pod placement to specific nodes. This
is applied to the pods created in all namespaces and creates an
intersection with any existing nodeSelectors already set on a pod,
additionally constraining that pod''s selector. For example, defaultNodeSelector:
"type=user-node,region=east" would set nodeSelector field in pod
spec to "type=user-node,region=east" to all pods created in all
namespaces. Namespaces having project-wide node selectors won''t
be impacted even if this field is set. This adds an annotation section
to the namespace. For example, if a new namespace is created with
node-selector=''type=user-node,region=east'', the annotation openshift.io/node-selector:
type=user-node,region=east gets added to the project. When the openshift.io/node-selector
annotation is set on the project the value is used in preference
to the value we are setting for defaultNodeSelector field. For instance,
openshift.io/node-selector: "type=user-node,region=west" means that
the default of "type=user-node,region=east" set in defaultNodeSelector
would not be applied.'
type: string
mastersSchedulable:
description: 'MastersSchedulable allows masters nodes to be schedulable.
When this flag is turned on, all the master nodes in the cluster
will be made schedulable, so that workload pods can run on them.
The default value for this field is false, meaning none of the master
nodes are schedulable. Important Note: Once the workload pods start
running on the master nodes, extreme care must be taken to ensure
that cluster-critical control plane components are not impacted.
Please turn on this field after doing due diligence.'
type: boolean
policy:
description: 'DEPRECATED: the scheduler Policy API has been deprecated
and will be removed in a future release. policy is a reference to
a ConfigMap containing scheduler policy which has user specified
predicates and priorities. If this ConfigMap is not available scheduler
will default to use DefaultAlgorithmProvider. The namespace for
this configmap is openshift-config.'
properties:
name:
description: name is the metadata.name of the referenced config
map
type: string
required:
- name
type: object
profile:
description: "profile sets which scheduling profile should be set
in order to configure scheduling decisions for new pods. \n Valid
values are \"LowNodeUtilization\", \"HighNodeUtilization\", \"NoScoring\"
Defaults to \"LowNodeUtilization\""
enum:
- ""
- LowNodeUtilization
- HighNodeUtilization
- NoScoring
type: string
profileCustomizations:
description: profileCustomizations contains configuration for modifying
the default behavior of existing scheduler profiles.
properties:
dynamicResourceAllocation:
description: dynamicResourceAllocation allows to enable or disable
dynamic resource allocation within the scheduler. Dynamic resource
allocation is an API for requesting and sharing resources between
pods and containers inside a pod. Third-party resource drivers
are responsible for tracking and allocating resources. Different
kinds of resources support arbitrary parameters for defining
requirements and initialization. Valid values are Enabled, Disabled
and omitted. When omitted, this means no opinion and the platform
is left to choose a reasonable default, which is subject to
change over time. The current default is Disabled.
enum:
- ""
- Enabled
- Disabled
type: string
type: object
type: object
status:
description: status holds observed values from the cluster. They may not
be overridden.
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
14 changes: 14 additions & 0 deletions config/v1/custom.scheduler.testsuite.yaml
@@ -0,0 +1,14 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "[Stable] Scheduler"
crd: 0000_10_config-operator_01_scheduler-CustomNoUpgrade.crd.yaml
tests:
onCreate:
- name: Should be able to create a minimal Scheduler
initial: |
apiVersion: config.openshift.io/v1
kind: Scheduler
spec: {} # No spec is required for a Scheduler
expected: |
apiVersion: config.openshift.io/v1
kind: Scheduler
spec: {}
2 changes: 1 addition & 1 deletion config/v1/stable.scheduler.testsuite.yaml
@@ -1,6 +1,6 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "[Stable] Scheduler"
crd: 0000_10_config-operator_01_scheduler.crd.yaml
crd: 0000_10_config-operator_01_scheduler-Default.crd.yaml
tests:
onCreate:
- name: Should be able to create a minimal Scheduler
Expand Down
14 changes: 14 additions & 0 deletions config/v1/techpreview.scheduler.testsuite.yaml
@@ -0,0 +1,14 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "[Stable] Scheduler"
crd: 0000_10_config-operator_01_scheduler-TechPreviewNoUpgrade.crd.yaml
tests:
onCreate:
- name: Should be able to create a minimal Scheduler
initial: |
apiVersion: config.openshift.io/v1
kind: Scheduler
spec: {} # No spec is required for a Scheduler
expected: |
apiVersion: config.openshift.io/v1
kind: Scheduler
spec: {}
28 changes: 28 additions & 0 deletions config/v1/types_scheduling.go
Expand Up @@ -42,6 +42,10 @@ type SchedulerSpec struct {
// Defaults to "LowNodeUtilization"
// +optional
Profile SchedulerProfile `json:"profile,omitempty"`
// profileCustomizations contains configuration for modifying the default behavior of existing scheduler profiles.
// +openshift:enable:FeatureSets=CustomNoUpgrade;TechPreviewNoUpgrade
// +optional
ProfileCustomizations ProfileCustomizations `json:"profileCustomizations"`
ingvagabund marked this conversation as resolved.
Show resolved Hide resolved
// defaultNodeSelector helps set the cluster-wide default node selector to
// restrict pod placement to specific nodes. This is applied to the pods
// created in all namespaces and creates an intersection with any existing
Expand Down Expand Up @@ -93,6 +97,30 @@ var (
NoScoring SchedulerProfile = "NoScoring"
)

// ProfileCustomizations contains various parameters for modifying the default behavior of certain profiles
type ProfileCustomizations struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, how many other fields do you expect to be present here? Is it possible any will be mutually exclusive from one another?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how many other fields do you expect to be present here?

Hard to say. I can think of another one for changing the bin-packing weight.

Is it possible any will be mutually exclusive from one another?

Only a single profile is active at the same time. It can happen though it's going to be limited.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok maybe I should rephrase then, I see that the profile is selectable above, can the dynamic resource allocation field be set with each and every profile option in that enum?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the dra is valid for all three profiles.

// dynamicResourceAllocation allows to enable or disable dynamic resource allocation within the scheduler.
// Dynamic resource allocation is an API for requesting and sharing resources between pods and containers inside a pod.
// Third-party resource drivers are responsible for tracking and allocating resources.
// Different kinds of resources support arbitrary parameters for defining requirements and initialization.
// Valid values are Enabled, Disabled and omitted.
// When omitted, this means no opinion and the platform is left to choose a reasonable default,
// which is subject to change over time.
// The current default is Disabled.
// +optional
DynamicResourceAllocation DRAEnablement `json:"dynamicResourceAllocation"`
ingvagabund marked this conversation as resolved.
Show resolved Hide resolved
}

// +kubebuilder:validation:Enum:="";"Enabled";"Disabled"
type DRAEnablement string
ingvagabund marked this conversation as resolved.
Show resolved Hide resolved

var (
// DRAEnablementEnabled enables dynamic resource allocation feature
DRAEnablementEnabled DRAEnablement = "Enabled"
// DRAEnablementDisabled disables dynamic resource allocation feature
DRAEnablementDisabled DRAEnablement = "Disabled"
)

type SchedulerStatus struct {
}

Expand Down
17 changes: 17 additions & 0 deletions config/v1/zz_generated.deepcopy.go

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