In-place Resource Resize for Kubernetes (> 1.27) Pods is not working through Java client #3450
Labels
lifecycle/rotten
Denotes an issue or PR that has aged beyond stale and will be auto-closed.
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):
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.
The text was updated successfully, but these errors were encountered: