I am deploying plain pod yaml file. Attached is the snapshot of Pod.
My requirement is I want to update entire pod whenever its required. This can be achieved by using kubectl replace command with force, it will take care of deleting and re-creating it.
Command is kubectl replace -f pod.yaml --force
.
The RestAPI for replace is PUT (https://kubernetes-url/api/v1/namespaces/default/pods/test-pod) What query parameter I need to pass to achieve force replace through rest api similar to kubectl force replace.
When you use --force
internally it deletes the pod and create it again. PUT
verb is not used in this case and there is no parameter for force in the REST API. You need to make two REST API call
First with DELETE
verb to https://kubernetes-url/api/v1/namespaces/default/pods/test-pod
Second with POST
verb to https://kubernetes-url/api/v1/namespaces/default/pods/test-pod
You can verify what REST API call is being made by running the command in verbose mode.
kubectl replace -f pod.yaml --force --v=8