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

✨ Configurable qos resources for deployments managed by clustermanager and klusterlet #316

Merged

Conversation

dongbeiqing91
Copy link
Contributor

Summary

Support configurable qos resources for deployments managed by clustermanager and klusterlet because "Default" deployment resources w/ only hard coded "resources" but no "limits" is not good enough and "BestEffort" is usually not allowed in production.

Related issue(s)

Fixes #

@openshift-ci openshift-ci bot requested review from deads2k and mdelder January 18, 2024 06:24
@dongbeiqing91
Copy link
Contributor Author

/assign @qiujian16

@dongbeiqing91 dongbeiqing91 changed the title configurable qos resources for deployments managed by clustermanager and klusterlet ✨ Configurable qos resources for deployments managed by clustermanager and klusterlet Jan 18, 2024
)

// ResourceRequirement allow user override the default pod QoS classes
type ResourceRequirement struct {
// +kubebuilder:validation:Enum=Default;BestEffort
// +kubebuilder:default:=Default
Type ResourceQosClass `json:"type"`
// Resources defines resource requests and limits when Type is ResourceQosClassConfigurable
// +optional
Resources *corev1.ResourceList `json:"resources,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

You would need to add ResourceQosClassConfigurable in the // +kubebuilder:validation:Enum=Default;BestEffort for type.

I would suggest the type is ResourceRequirements and the field name should be ResourceRequirements too.

Copy link
Contributor Author

@dongbeiqing91 dongbeiqing91 Jan 18, 2024

Choose a reason for hiding this comment

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

Added ResourceQosClassConfigurable in the validation comment

I would suggest the type is ResourceRequirements and the field name should be ResourceRequirements too

Do you mean changing

ResourceRequirement *ResourceRequirement `json:"resourceRequirement,omitempty"`

to

ResourceRequirements *ResourceRequirements `json:"resourceRequirement,omitempty"`

But json:"resourceRequirement,omitempty" has to stay unchanged, right?

Copy link
Member

Choose a reason for hiding this comment

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

ResourceRequirement *ResourceRequirement json:"resourceRequirement,omitempty" is ok

)

// ResourceRequirement allow user override the default pod QoS classes
type ResourceRequirement struct {
// +kubebuilder:validation:Enum=Default;BestEffort
// +kubebuilder:default:=Default
Type ResourceQosClass `json:"type"`
// Resources defines resource requests and limits when Type is ResourceQosClassConfigurable
// +optional
Resources *corev1.ResourceList `json:"resources,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I do not think *corev1.ResourceList is the correct type. What you want is https://github.com/kubernetes/api/blob/master/core/v1/types.go#L2547?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you are right. Fixed.


// ResourceRequirement specify QoS classes of deployments managed by clustermanager
// +optional
ResourceRequirement *ResourceRequirement `json:"resourceRequirement,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

it should be noted that it applies to all containers since there are multiple containers running in the cluster manager.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

comment added

@zhiweiyin318
Copy link
Member

the deepcopy go file is not updated, is there any error durning running the make update?

@dongbeiqing91
Copy link
Contributor Author

the deepcopy go file is not updated, is there any error durning running the make update?

It indeeded had some errors I didn't pay attention to. Let me check and fix it

@dongbeiqing91
Copy link
Contributor Author

the deepcopy go file is not updated, is there any error durning running the make update?

The project path was wrong. I have fixed it. deepcopy is correctly generated now.

ResourceQosClassDefault ResourceQosClass = "Default"
// If all containers in the pod don't set resource request and limits, the pod is treated as BestEffort.
ResourceQosClassBestEffort ResourceQosClass = "BestEffort"
// Configurable resources with requests and limits
ResourceQosClassConfigurable ResourceQosClass = "Configurable"
Copy link
Member

@qiujian16 qiujian16 Jan 18, 2024

Choose a reason for hiding this comment

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

the type name should be ResourceRequirement

ResourceQosClassResourceRequirement ResourceQosClass = "ResourceRequirement"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

// +kubebuilder:default:=Default
Type ResourceQosClass `json:"type"`
// Resources defines resource requests and limits when Type is ResourceQosClassResourceRequirement
// +optional
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
ResourceRequirement *corev1.ResourceRequirements `json:"resourceRequirement,omitempty"`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if this change is made, the yaml will look like:

resourceRequirement:
  resourceRequirement:
    limits: 
       ...

duplicated resourceRequirements look weild I suppose

Copy link
Contributor Author

@dongbeiqing91 dongbeiqing91 Jan 18, 2024

Choose a reason for hiding this comment

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

In kubernetes Container struct, it is

Resources ResourceRequirements `json:"resources,omitempty" protobuf:"bytes,8,opt,name=resources"`

https://github.com/kubernetes/api/blob/master/core/v1/types.go#L2682

Copy link
Member

@qiujian16 qiujian16 Jan 19, 2024

Choose a reason for hiding this comment

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

it is intended to follow the union pattern https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/1027-api-unions/README.md. So either the type should be Resources or the filed name should be ResourceRequirement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@zhiweiyin318
Copy link
Member

the DCO Check requires a Signed-off-by trailer in the commit log. so you need to add -s when run git commit.

@dongbeiqing91
Copy link
Contributor Author

the DCO Check requires a Signed-off-by trailer in the commit log. so you need to add -s when run git commit.

Done

@qiujian16
Copy link
Member

/approve
/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jan 22, 2024
Copy link
Contributor

openshift-ci bot commented Jan 22, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: promid, qiujian16

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants