PortForward and kubectl proxy, it showed external IP as pending.

 
kubectl patch svc <svc-name> -n <namespace> -p  
'{"spec": {"type": "LoadBalancer", "externalIPs":["172.31.71.218"]}}'
 
      

kubectl - How to edit service spec type to LoadBalancer via command line?

You can't remove the existing port, but you can add the HTTPs port and also change the type using kubectl patch

Example:

kubectl patch svc <my_service> -p '{"spec": 
{"ports": [{"port": 443,"targetPort": 443,"name": "https"},
{"port": 80,"targetPort": 80,"name": "http"}],"type": "LoadBalancer"}}'
 

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

ports:
  - port: 443
    targetPort: 443
    name: "https"
  - port: 80
    targetPort: 80
    name: "http"
  type: LoadBalancer

 

And then do:

kubectl patch svc <my_service> --patch "$(cat patch.yaml)"
 
 
 
 
Previous Post Next Post