<p>I am trying to assign <strong>clusterIP</strong> to a <strong>Service</strong> in the kube cluster.
I know the IP range, so that I can form new IPs from that IP range.</p>

<p>I am implementing proxy within containers. So I need to know the clusterIP of the depending services, so that I can do a proxy from the source container. For this purpose I am specifying the clusterIP at the time of creating a service.</p>

<p>Now the challenge is that I should allocate an IP that is not used by any other service within that cluster, else it will fail.</p>

<p>What I did is the following. I got the list of <strong>Services and their IPs</strong> in that kube cluster and formed a new IP and made sure that the new IP is not in the pool of IPs already in use and then allocated it to the new service. It works fine in most of the cases.</p>

<p>Now I am facing a strange issue here.<br>
In some cases it fails saying that <strong>"Service 'mongodb-4-xmxrv-svc' is invalid: spec.clusterIP: Invalid value: '10.7.240.2': provided IP is already allocated"</strong>.</p>

<p>But that IP is not used by any of the <strong>Services</strong> within that kube cluster. I am not sure where that IP is used. Can someone help me out to list the IPs that are used within that kube cluster, so that I can form a new IP and allocate it to the <strong>Service</strong>?</p>

<p>You can look at all services in all namespaces using:</p>

<pre><code>kubectl get services --all-namespaces
</code></pre>

<p>It's likely that a service in the <code>kube-system</code> namespace has the 10.7.240.2 address. </p>
