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

Use protobuf encoding for core K8s APIs in kueue #3077

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

tosi3k
Copy link
Contributor

@tosi3k tosi3k commented Sep 17, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

For core K8s API objects like Pods, Nodes, etc., we can use protobuf encoding which, compared to the default JSON encoding, reduces CPU consumption related to (de)serialization, reduces overall latency of the API calls, reduces memory footprint and the work performed by the GC and results in quicker propagation of objects to event handlers of shared informers.

Core system components of K8s default their serialization method to protobuf for 8 years already: kubernetes/kubernetes#25738.

Which issue(s) this PR fixes:

No issue is opened for that.

Special notes for your reviewer:

Some benchmarks comparing JSON vs. protobuf showcasing how the latter data format (de)serializes faster and uses less memory:

Does this PR introduce a user-facing change?

CLI: Use protobuf encoding for core K8s APIs in kueuectl.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. labels Sep 17, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 17, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @tosi3k!

It looks like this is your first PR to kubernetes-sigs/kueue 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kueue has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 17, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @tosi3k. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for kubernetes-sigs-kueue ready!

Name Link
🔨 Latest commit 517e7b4
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/66e973726ae18800082129b3
😎 Deploy Preview https://deploy-preview-3077--kubernetes-sigs-kueue.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 17, 2024
@alculquicondor
Copy link
Contributor

/assign @gabesaba

@alculquicondor
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 17, 2024
@gabesaba
Copy link
Contributor

/lgtm

thanks for the patch

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 17, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 85ce0f9f9ac09871fb0e038e587831281dde9f53

Copy link
Contributor

@alculquicondor alculquicondor left a comment

Choose a reason for hiding this comment

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

What about the Kueue controller manager? Can that be changed to use protobuf too?

Also, are there apiservers that don't support protobuf?

@tosi3k
Copy link
Contributor Author

tosi3k commented Sep 17, 2024

Also, are there apiservers that don't support protobuf?

Protobuf support for core K8s APIs was added in K8s 1.3 and it's essentially embedded in apiserver - you can't really turn it off anyhow.

What about the Kueue controller manager? Can that be changed to use protobuf too?

If we are touching some custom resources there, then not really - CRs nor dynamic clientsets do not support protobuf encoding.

OTOH, I noticed it uses NewManager function from the controller-runtime repo. A comment above that function's definition implies it would use protobuf for the core API types underneath (link):

// NewManager returns a new Manager for creating Controllers.
// Note that if ContentType in the given config is not set, "application/vnd.kubernetes.protobuf"
// will be used for all built-in resources of Kubernetes, and "application/json" is for other types
// including all CRD resources.

@alculquicondor
Copy link
Contributor

Thank you @tosi3k for the extra context and @mbobrovskyi for the investigation :)

@alculquicondor
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, tosi3k

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 17, 2024
@k8s-ci-robot k8s-ci-robot merged commit e812a06 into kubernetes-sigs:main Sep 17, 2024
17 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.9 milestone Sep 17, 2024
@mimowo
Copy link
Contributor

mimowo commented Sep 18, 2024

IIUC the change only affects the kueuectl client. Also, is this in fact just for core types?

I would suggest to say in release notes:

CLI: Use protobuf encoding for the client used by kueuectl.

WDYT @tosi3k ?

@tosi3k
Copy link
Contributor Author

tosi3k commented Sep 18, 2024

Also, is this in fact just for core types?

Yes - as already stated, custom resources do not support protobuf.

If you try using application/vnd.kubernetes.protobuf content type when talking to K8s API about custom resources, you'd receive an error analogous to the one Mykhailo pasted above.

IIUC the change only affects the kueuectl client.

The PR also touches kjobctl which is not a part of kueuectl, no?

@mimowo
Copy link
Contributor

mimowo commented Sep 18, 2024

The PR also touches kjobctl which is not a part of kueuectl, no?

kjobctl is not released yet as part of Kueue, so we don't mention it in release notes yet (for any features)

@mimowo
Copy link
Contributor

mimowo commented Sep 18, 2024

Yes - as already stated, custom resources do not support protobuf.

I see, I missed that.

So, I would suggest release note (to emphasize this is just for Kueuectl which is a separate client binary from Kueue):

CLI: Use protobuf encoding for core K8s APIs in Kueuectl.

@tosi3k
Copy link
Contributor Author

tosi3k commented Sep 18, 2024

Done

kannon92 pushed a commit to openshift-kannon92/kubernetes-sigs-kueue that referenced this pull request Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants