Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move pods between namespace

Tags:

kubernetes

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?

like image 915
Chris G. Avatar asked Jan 15 '20 16:01

Chris G.


People also ask

Can pods communicate between namespaces?

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.

How do I switch between namespaces in Kubernetes?

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.

Can a pod have multiple namespaces?

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!


1 Answers

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.

like image 73
Shashank V Avatar answered Oct 17 '22 03:10

Shashank V