Can use kubectl replace update the namespace of service in kubernetes

9/17/2015

Can use kubectl replace update the namespace of service in kubernetes?

the kubernetes master is in the default namespace, I want to change to kube-system namespace. So I did it as follow:

kubectl get svc kubernetes -o yaml > temp.yaml

This generate temp.yaml use current kubernetes service info, then I change the value of namespace to kube-system in temp.yaml and exec like:

kubectl replace -f temp.yaml

But I got the error:

Error from server: error when replacing "temp.yaml": service "kubernetes" not found

I think there is none service named kubernetes in the kube-system namespace.

Who can tell me how can to do this ?

-- sope
docker
kubernetes

2 Answers

9/18/2015

The kubernetes service is special and exists in the default namespace. Too may things assume that to change it safely.

-- Tim Hockin
Source: StackOverflow

9/17/2015

Name and namespace are immutable on objects. When you try to change the namespace, replace looks for the service in the new namespace in order to overwrite it. You should be able to do create -f ... to create the service in the new namespace

-- Jordan Liggitt
Source: StackOverflow