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 ?
The kubernetes
service is special and exists in the default
namespace. Too may things assume that to change it safely.
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