<p>I have a k8s service of type clusterIP.. i need to change the below configuration via CLI</p>

<ol>
<li>the http port to https port</li>
<li>the port number</li>
<li>the type to Load Balancer</li>
</ol>

<p>Is there a way to do it..?</p>

<p>You can't remove the existing port, but you <em>can</em> add the HTTPs port and also change the type using <a href="https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/" rel="noreferrer">kubectl patch</a></p>

<p>Example:</p>

<pre><code>kubectl patch svc &lt;my_service&gt; -p '{"spec": {"ports": [{"port": 443,"targetPort": 443,"name": "https"},{"port": 80,"targetPort": 80,"name": "http"}],"type": "LoadBalancer"}}'
</code></pre>

<p>If you don't want to create JSON on the command line, create a yaml file like so:</p>

<pre><code>ports:
  - port: 443
    targetPort: 443
    name: "https"
  - port: 80
    targetPort: 80
    name: "http"
  type: LoadBalancer
</code></pre>

<p>And then do:</p>

<pre><code>kubectl patch svc &lt;my_service&gt; --patch "$(cat patch.yaml)"
</code></pre>
