-
-
Notifications
You must be signed in to change notification settings - Fork 357
add resize subresource for Pods #1794
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
base: main
Are you sure you want to change the base?
Conversation
Implement the resize subresource for Kubernetes Pods as specified in GitHub issue kube-rs#1793. The resize subresource allows changing resource requirements (CPU/memory limits and requests) for containers in running pods, available in Kubernetes 1.33+. Changes: - Add Request::resize method in kube-core for PATCH requests to /resize endpoint - Add Resize marker trait and Api::resize method in kube-client with k8s_if_ge_1_33 version gating - Include test for resize URL construction - Add pod_resize example demonstrating usage with resource limit modifications Closes kube-rs#1793 Signed-off-by: Krishna Ketan Rai <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1794 +/- ##
=======================================
- Coverage 75.2% 75.1% -0.0%
=======================================
Files 84 84
Lines 7791 7809 +18
=======================================
+ Hits 5853 5859 +6
- Misses 1938 1950 +12
🚀 New features to boost your workflow:
|
Implements the resize subresource for Kubernetes Pods following the same patterns as other subresources in kube-rs. Changes: - Add Request::resize method in kube-core for PATCH requests to /resize - Add Resize trait and Api::resize method in kube-client (gated on k8s_if_ge_1_33) - Add resize URL construction test - Add pod_resize example demonstrating usage The resize subresource allows updating pod resource requests/limits and is available in Kubernetes 1.33+. Fixes kube-rs#1793 Signed-off-by: Krishna Ketan Rai <[email protected]>
hey, thanks for this. Very quick response to this issue :-) travelling today, but should be able to review later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this. example is sensible, and the method you have for one of the verbs seems sensible. it's missing the 2 other verbs which should be a similar job. you can look at how scale
or ephemeral_containers
is set up for multiple verbs.
left some minor comments, but documentation and general pattern is nice.
let pods: Api<Pod> = Api::default_namespaced(client); | ||
|
||
// Resize is only available in Kubernetes 1.33+ | ||
k8s_openapi::k8s_if_ge_1_33! { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to gate the example on 1_33 because the we have latest
as a required feature
/// This works similarly to [`Api::replace`] but uses the resize subresource. | ||
/// Takes a full Pod object to specify the new resource requirements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should link to limitations
/// # Ok(()) | ||
/// # } | ||
/// ``` | ||
pub async fn resize(&self, name: &str, pp: &PostParams, data: &K) -> Result<K> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
misses support for the other verbs get/patch. need to rename this to replace_resize
to make room for patch_resize
and get_resize
Motivation
This PR implements the
resize
subresource for Kubernetes Pods as requested in issue #1793. The resize subresource is a new feature introduced in Kubernetes 1.33 that allows users to modify resource requirements (CPU and memory limits/requests) for containers in running pods without having to restart the pod.Solution
This implementation adds complete support for the resize subresource following existing patterns in the kube-rs codebase:
Core Changes
kube-core/src/subresource.rs
: AddedRequest::resize()
method that constructs PATCH requests to the/resize
endpoint, following the same pattern as other subresources likeevict()
andscale()
kube-client/src/api/subresource.rs
: AddedResize
marker trait andApi::resize()
method with proper version gating usingk8s_if_ge_1_33!
macroresize_path
test to verify correct URL constructionexamples/pod_resize.rs
demonstrating practical usage with resource limit modificationsUsage