Manual Scheduling Practice Test

While working on the Manual Scheduling Practice Test I am also faced the same problem as Santash. I do change the curl command as suggested by Vijin. But I am not able to schedule the pod using the command as per question number 3 where it says to schedule the pod to “node01”. Then I delete the pod and rec-create the same by manually entering the “nodeName” parameter. Then while trying to answer question number 4 to schedule the same pod to “master” node, I tried the curl command but receiving the failure message.

master $ curl --header “Content-Type:application/json” --request POST --data ‘{“apiVersion”: “v1”, “kind”: “Binding”, “metadata”: {“name”: “nginx”}, “target”: {“apiVersion”: “v1”, "kind: “Node”, “name”: “node01”}}’ -k https://172.17.0.61:6443/api/v1/namespaces/default/pods/nginx/binding/
{
“kind”: “Status”,
“apiVersion”: “v1”,
“metadata”: {

},
“status”: “Failure”,
“message”: “pods "nginx" is forbidden: User "system:anonymous" cannot create resource "pods/binding" in API group "" in the namespace "default"”,
“reason”: “Forbidden”,
“details”: {
“name”: “nginx”,
“kind”: “pods”
},
“code”: 403

Please help.

Thanks,
Kunal

Hello Santash Jena,

As this worked for you. Could you please provide me the command that you had used in your case. Which succeeded.

Thanks,
Kunal

Guys… I have the same issue, can anyone help me in manual scheduling using CURL?

run ‘kubectl proxy &’ it will open 8001 port on localhost
Use the localhost:8001 as server address while making the API call
curl --header “Content-type: application/json” --header “Authorization: Bearer $TOKEN” --request POST --data ‘{“apiVersion”: “v1”, “kind”: “Binding”, “metadata”: {“name”: “nginx”}, “target”: {“apiVersion”: “v1”, “kind”: “Node”, “name”: “controlplane”}}’ http://127.0.0.1:8001/api/v1/namespaces/default/pods/nginx/binding/
{
“kind”: “Status”,
“apiVersion”: “v1”,
“metadata”: {},
“status”: “Success”,
“code”: 201
}

I have just finished that lab. You can do it in following way

curl -L --cacert ca.crt --cert private-cert.pem --key private-key.pem -X POST ‘https://controlplane:6443/api/v1/namespaces/default/pods/nginx/binding’ -H ‘Content-Type: application/json’ --data ‘{“apiVersion”: “v1”, “kind”: “Binding”, “metadata”: {“name”: “nginx”}, “target”: { “apiVersion”: “v1”, “kind”: “Node”, “name”: “node01”}}’

For ‘ca.crt’ / ‘private-cert.pem’ / ‘private-key.pem’, you can get it from $HOME/.kube/config

awk ‘/certificate-authority-data/{print $NF}’ $HOME/.kube/config | base64 --decode > ca.crt
awk ‘/client-certificate-data/{print $NF}’ $HOME/.kube/config | base64 --decode > private-cert.pem
awk ‘/client-key-data/{print $NF}’ $HOME/.kube/config | base64 --decode > private-key.pem

How to get token for the API ‘Bearer $TOKEN’ ?