<p>I have a healthy k8s cluster. The kube-apiserver is using port <strong>8443</strong>.
Then I do something like below. I create/edit a Sevice and assign a fixed nodePort <strong>8443</strong>, too.</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: MyApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376
      nodePort: 8443
</code></pre>
<p>The cluster becomes unreachable. If I run command <code>kubectl get pods</code>. It returns <code>Unable to connect to the server: EOF</code></p>
<p>Cause I need run kubectl command to change the nodePort back. But I cannot use kubectl. It becomes a dead loop. I have 2 questions.</p>
<ol>
<li>What can I do to get my k8s cluster back?</li>
<li>Why kube-apiserver or other components doesn't prevent me to change the nodePort to <strong>8443</strong>? Indicate the port <strong>8443</strong> is already in use.</li>
</ol>

<blockquote>
<p>kube-apiserver pod is a static pod brought up by kubelet using /etc/kubernetes/manifests/kube-apiserver.yaml file on master nodes</p>
</blockquote>
<blockquote>
<p>so you can edit /etc/kubernetes/manifests/kube-apiserver.yaml ,
where 8443 port is referenced and change it to a unused port. so that kube-apiserver will be available on that port. ideally kubelet tries to restart a static pod when its manifest file is changed .</p>
</blockquote>
<blockquote>
<p>you need to edit ~/.kube/config , where 'server' address needs to be changed to new port.</p>
</blockquote>
<blockquote>
<p>delete the problematic nodeport service .</p>
</blockquote>
<blockquote>
<p>revert your changes in /etc/kubernetes/manifests/kube-apiserver.yaml &amp; .kube/config file    to go back to original port (8443)</p>
</blockquote>
