<p>Our Openshift cluster created with a following definition in network/cluster :</p>
<pre><code>spec:
  clusterNetwork:
  - cidr: 10.0.0.0/23
    hostPrefix: 26
  externalIP:
    autoAssignCIDRs:
    - 10.10.0.0/24
  networkType: Calico
  serviceNetwork:
  - 10.20.0.0/24
</code></pre>
<p>I am wondering if it possible to create service type ClusterIP (not LoadBalancer) and have ExternalIP automatically assigned to it ?</p>
<p>In case service defined as a LoadBalancer ( oc create svc loadblanacer my-service --tcp=80 ) auto-assignement works fine, however it expose the NodePort , which we are trying to avoid.</p>
<p>I can specify ExternalIP manually like <code>oc expose deploy my-deployment --external-ip=&quot;10.10.0.100 --port=80&quot;</code> , but trying to figure out if it can be done automatically.</p>

Andy
<p>Unfortunately, <code>ExternalIPs</code> field cannot be auto-filled under the <code>ClusterIP</code> service type. <code>ClusterIP</code> is designed for internal access only. The workaround in your case is not an intended behavior so it cannot be handled by the Service controller automatically.</p>
<p>Luckily saying, the issue you want to fix under the <code>LoadBalancer</code> type is a well-discussed issue in the community. A new patch has been merged into the latest Kubernetes code base.</p>
<p>Under the 1.20 <a href="https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.20.md" rel="nofollow noreferrer">CHANGELOG</a>, you can see a change here.</p>
<blockquote>
<p>Automatic allocation of NodePorts for services with type LoadBalancer can now be disabled by setting the (new) parameter Service.spec.allocateLoadBalancerNodePorts=false. The default is to allocate NodePorts for services with type LoadBalancer which is the existing behavior. (#92744, @uablrek) [SIG Apps and Network]</p>
</blockquote>
<p>So, when you upgrade your cluster to Kubernetes v1.20 and apply something like this.</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: example-service
spec:
  selector:
    app: example
  ports:
    - port: 8765
      targetPort: 9376
  allocateLoadBalancerNodePorts: false
  type: LoadBalancer
</code></pre>
<p>The node port allocation will be disabled and you can fix your issue without any hacky approach.</p>
