<p>The <code>kubernetes</code> service is in the <code>default</code> namespace. I want to move it to <code>kube-system</code> namespace. So I did it as follow:</p>
<pre class="lang-yaml prettyprint-override"><code>kubectl get svc kubernetes -o yaml &gt; temp.yaml
</code></pre>
<p>This generates <code>temp.yaml</code> using current <code>kubernetes</code> service information. Then I changed the value of namespace to <code>kube-system</code> in <code>temp.yaml</code>. Lastly, I ran the following command:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl replace -f temp.yaml
</code></pre>
<p>But I got the error:</p>
<pre><code>Error from server: error when replacing &quot;temp.yaml&quot;: service &quot;kubernetes&quot; not found
</code></pre>
<p>I think there is no service named <code>kubernetes</code> in the <code>kube-system</code> namespace.</p>
<p>Who can tell me how can to do this?</p>

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