<ol>
<li>eg. I have 2 pods, they were called <strong>nginx-111-xxx</strong>,
<strong>nginx-111-yyy</strong>, but there is <strong>something wrong in nginx-111-xxx</strong>, I need to create a new pod to replace it because
the demands acquire you to <strong>delete nginx-111-xxx</strong>, then a NEW pods
<strong>nginx-111-zzz</strong>, Can I <strong>rename nginx-111-zzz with nginx-111-xxx</strong>?   I try to use kubectl edit command to achieve it,</li>
<li>But Kubernetes said  <strong><em>copy of your changes has been stored to
"/tmp/kubectl-edit-oh43e.yaml" error: At least one of apiVersion,
kind and name was changed</em></strong>, so If there is a way to change the name of the running pod ?<a href="https://i.stack.imgur.com/8J2p6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8J2p6.png" alt="enter image description here"></a></li>
</ol>

Layne Liu
<p>It's not possible to change the name of a running pod, as the API will not accept this.</p>
<p>The random pod names come in fact you are using Kubernetes deployments, which are the default or most commonly used ways to run pods on Kubernetes. But there are different ways to schedule pods, beside of that.</p>
<p>However, it looks like you need more predictable pod names for some reason. Here are some ways to go:</p>
<ol>
<li>use StatefulSets (<a href="https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/</a>). The names of pods created by a StatefulSet will go like <strong>nginx-01</strong>, <strong>nginx-02</strong> ..</li>
<li>use pods directly. With that, you won't have those rolling update features from replicasets, DaemonSets etc, but absolute control about naming</li>
</ol>
