<p><strong>Background:</strong></p>

<p>Let's say I have a replication controller with some pods. When these pods were first deployed they were configured to expose port 8080. A service (of type LoadBalancer) was also create to expose port 8080 publicly. Later we decide that we want to export an additional port from the pods (port 8081). We change the pod definition and do a rolling-update with no downtime, great! But we want this port to be publicly accessible as well.</p>

<p><strong>Question:</strong></p>

<p>Is there a good way to update a service without downtime (for example by adding a an additional port to expose)? If I just do:</p>

<pre><code>kubectl replace -f my-service-with-an-additional-port.json
</code></pre>

<p>I get the following error message:</p>

<pre><code>Replace failedspec.clusterIP: invalid value '': field is immutable
</code></pre>

<p>If you name the ports in the pods, you can specify the target ports by name in the service rather than by number, and then the same service can direct target to pods using different port numbers.</p>

<p>Or, as Yu-Ju suggested, you can do a read-modify-write of the live state of the service, such as via kubectl edit. The error message was due to not specifying the clusterIP that had already been set.</p>
