Not a big deal, but just wondering what is best practice for moving pods from one namespace to another?
Do you just kubectl delete
and kubectl apply
?
By default, pods can communicate with each other by their IP address, regardless of the namespace they're in. However, the normal way to communicate within a cluster is through Service resources. A Service also has an IP address and additionally a DNS name.
By default, the kubectl command-line tool interacts with the default namespace. If you want to use a different namespace, you can pass kubectl the --namespace flag. For example, kubectl --namespace=mystuff references objects in the mystuff namespace.
You can think of a Namespace as a virtual cluster inside your Kubernetes cluster. You can have multiple namespaces inside a single Kubernetes cluster, and they are all logically isolated from each other. They can help you and your teams with organization, security, and even performance!
You cannot "move" a resource to another namespace. There might be resource with same name in the other namespace already.
So yes, you need to delete the existing pod and recreate it in the other namespace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With