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

In-place Resource Resize for Kubernetes (> 1.27) Pods is not working through Java client #3450

Open
chandragm opened this issue May 30, 2024 · 2 comments
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

Comments

@chandragm
Copy link

chandragm commented May 30, 2024

Describe the bug
https://kubernetes.io/blog/2023/05/12/in-place-pod-resize-alpha/
In-place Resource Resize for Kubernetes (> 1.27) Pods is working when using the kubectl patch command as mentioned in the linked blog. Meaning the container's resources cpu/ memory get updated in-place without restarting or new containers being created.

I am following (https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/) to achieve similar functionality.

https://github.com/kubernetes-client/java/blob/master/examples/examples-release-18/src/main/java/io/kubernetes/client/examples/PatchExample.java

I tried PatchUtils.patch with
V1Patch body: "[{ \"op\": \"replace\", \"path\": \"/spec/template/spec/containers/0/resources/limits/cpu\", \"value\": \"1\" }]" for PATCH_FORMAT_JSON_PATCH. From the documentation it says that the new pods will be created.

Would like to understand how to update in-place without the creation of new pods.

Client Version
20.0.1

Kubernetes Version
Client Version: v1.29.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.28.3

Java Version
Java 17

To Reproduce
https://github.com/kubernetes-client/java/blob/master/examples/examples-release-18/src/main/java/io/kubernetes/client/examples/PatchExample.java

Try any of the patch deployment variations and you should see the pods getting created anew. Instead the pod spec has to be updated in-place.

Expected behavior
Pods should not get created anew but the cpu/memory resource requests and limits get updated in-place.

KubeConfig
apiVersion: apps/v1 kind: Deployment metadata: name: inplacedemo spec: replicas: 1 selector: matchLabels: app: inplacedemo template: metadata: labels: app: inplacedemo spec: containers: - name: inplacedemo image: alpine command: ["tail", "-f", "/dev/null"] resizePolicy: - resourceName: "memory" restartPolicy: "RestartContainer" resources: limits: cpu: 2 memory: "1Gi" requests: cpu: 1 memory: "500Mi"

Server (please complete the following information):

  • OS: Mac
  • Environment : Local Minikube cluster
  • Cloud : NA

Additional context
I would like to achieve the equivalent of https://kubernetes.io/blog/2023/05/12/in-place-pod-resize-alpha/ using the java client.

@brendandburns
Copy link
Contributor

Two things.

  1. it appears that you are patching the Deployment, and not the Pods themselves. In place resource update only works at the pod level afaik. (though I could be wrong). You should try patching the Pods directly.

  2. If that doesn't work, I would suggest that you add --v=10 to the kubectl command line, that will print out the verbose data on all of the HTTP calls that kubectl is making. That should help you get some insight into the differences between what the java client is doing and what kubectl is doing to make this work.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

No branches or pull requests

4 participants