NdFeB:
Hello. I have two questions about the Manual Scheduling lab. On the last question, I wanted to use the Binding method to move my Pod from node01 to controlplane. The course states that you cannot change the nodeName
spec of an existing Pod, but you can mimic what the scheduler does by POSTing a Binding object to the binding API of an existing Pod.
The following returns a 409 error code, with message pod nginx is already assigned to node \"node01\"
. Kube version is 1.23.0. Why does it not work? Am I misunderstanding the course?
$ cat binding.yaml
apiVersion: v1
kind: Binding
metadata:
name: nginx
target:
apiVersion: v1
kind: Node
name: controlplane
$ curl --cert crt.pem --key key.pem --cacert cacert.pem -X POST -H 'Content-Type:application/json' --data "$(cat binding.yaml | yq eval -o json)" <https://controlplane:6443/api/v1/namespaces/default/pods/nginx/binding/>
Radoslaw Czajkowski:
i don’t know of this “binding” resource and from what i checked it is already deprecated “Binding ties one object to another; for example, a pod is bound to a node by a scheduler. Deprecated in 1.7, please use the bindings subresource of pods instead.” What do you want to achieve? You cannot migrate the pod from one node to another. The pod once scheduled on a particular node stays on it until it is deleted.
NdFeB:
The <https://kubernetes.io/docs/reference/kubernetes-api/cluster-resources/binding-v1/|official doc> states that Binding is indeed deprecated in 1.7, but also that we should “use the bindings subresource of pods instead”. I thought that /api/v1/namespaces/default/pods/nginx/binding/ was the actual “binding subresource” for the pod default/pod/nginx in my case.
Maybe i misunderstood the course, and this method can only be used to force scheduling if the scheduler is not available (or cannot schedule the Pod for whatever reason), and the Pod is in “Pending” state (not scheduled yet). I might need to do some tests.