<p>Can the Kubernetes NodePort service port change upon service restart or pod crash? How do you ensure that the port of NodePort service remains the same?</p>

randhir singh
<p>From <a href="https://kubernetes.io/docs/concepts/services-networking/service/#nodeport" rel="nofollow noreferrer">documentation</a></p>

<blockquote>
  <p>If you set the <strong>type</strong> field to <strong>NodePort</strong>, the Kubernetes master will allocate a port from a range specified by <strong>--service-node-port-range</strong> flag (default: 30000-32767), and each Node will proxy that port (the same port number on every Node) into your Service. That port will be reported in your <strong>Service</strong>’s <strong>.spec.ports[*].nodePort</strong> field.</p>
</blockquote>

<p>Pod crash or restart will not change your NodePort. Re-creating your service will.</p>

<p>You can specify a custom NodePort as described in <a href="https://stackoverflow.com/a/43944385/7568391">this answer</a>, this will keep Service's NodePort the same</p>
