<p>After creating a deployment with Kubernetes Python Client , and exposing the service with type ClusterIP, how can i get the Cluster-IP using the python client instead of using Kubectl command ?</p>
<p>Service was created based on the example code</p>
<pre><code>def create_service():
core_v1_api = client.CoreV1Api()
body = client.V1Service(
    api_version=&quot;v1&quot;,
    kind=&quot;Service&quot;,
    metadata=client.V1ObjectMeta(
        name=&quot;service-example&quot;
    ),
    spec=client.V1ServiceSpec(
        selector={&quot;app&quot;: &quot;deployment&quot;},
        ports=[client.V1ServicePort(
            port=5678,
            target_port=5678
        )]
    )
)
# Creation of the Deployment in specified namespace
# (Can replace &quot;default&quot; with a namespace you may have created)
core_v1_api.create_namespaced_service(namespace=&quot;default&quot;, body=body) 
</code></pre>
<p>There is a command to list pod ips on the documentation</p>
<pre><code>v1 = client.CoreV1Api()
print(&quot;Listing pods with their IPs:&quot;)
ret = v1.list_pod_for_all_namespaces(watch=False)
for i in ret.items:
    print(&quot;%s\t%s\t%s&quot; %
          (i.status.pod_ip, i.metadata.namespace, i.metadata.name))
</code></pre>
<p>im wondering if there's a way to do something similar with Cluster-IP from services.</p>

<p>Simply get the service and read its <code>spec.cluster_ip</code> property:</p>
<pre class="lang-py prettyprint-override"><code>from kubernetes import client, config
config.load_kube_config()
api = client.CoreV1Api()
service = api.read_namespaced_service(name=&quot;kubernetes&quot;, namespace=&quot;default&quot;)
print(service.spec.cluster_ip)
# 10.100.0.1
</code></pre>
