0
votes

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. enter image description here

1
Can you replace that screen shot with the actual YAML for your pod spec? (You can't kubectl apply -f a PNG file.)David Maze

1 Answers

1
votes

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

  1. First with DELETE verb to https://kubernetes-url/api/v1/namespaces/default/pods/test-pod

  2. 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