how to change kubernetes pod namespace

1/26/2020

I am created a pod in default namespace in kubernetes,but now I want to move pod to dabai-fat namespace I current created.I am trying to modify the yaml file but it give error:

the namespace of the object (dabai-fat) does not match the namespace on the request (default)

what should I do to make it work,should I delete the old pod and created a new pod?

-- Dolphin
kubernetes

1 Answer

1/26/2020

Yes, you should delete the old pod and recreate the new pod in the desired namespace.

You cannot move kubernetes resources between namespaces. Combination of name and namespace identifies a resource uniquely. So you cannot move the resource to a different namespace as another resource might already be present in the other namespace with same name.

-- Shashank V
Source: StackOverflow