<p>I need a way to get service cluster ip range (as CIDR) that works accross all Kubernetes clusters.</p>

<p>I tried the following, which works fine for clusters created with kubeadm as it greps arguments of apiserver pod:</p>

<pre><code>$ kubectl cluster-info dump  | grep service-cluster-ip-range
                        "--service-cluster-ip-range=10.96.0.0/12",
</code></pre>

<p>This does not work on all Kubernetes clusters, i.e. gcloud</p>

<p>So the question is, what is the best way to get service ip range programatically?</p>

<p>I don't think there is a way to access such information through K8s Api, there is an open issue to address lack of this functionality: <a href="https://github.com/kubernetes/kubernetes/issues/25533" rel="nofollow noreferrer">https://github.com/kubernetes/kubernetes/issues/25533</a> . If you have access to the etcd of the k8s cluster in question, then there is a key with information about service cidr range: <code>/registry/ranges/serviceips</code> . You can get the value, by using etcdctl (assuming, you have the proper permissions): <code>etcdctl --enpoints=&lt;your etcd&gt; --&lt;any authentication flags&gt; get "/registry/ranges/serviceips" --prefix=true</code>.</p>
