<p>Among a big stack of orchestrated k8s pods, I have following two pods of interest:</p>
<ol>
<li>Elasticsearch pod attached to a PV</li>
<li>A tomcat based application pod that serves as administrator for all other pods</li>
</ol>
<p>I want to be able to query and display very minimal/basic disk availability and usage statistics of the PV (attached to pod #1) on the app running in pod #2</p>
<p>Can this be achieved without having to run a web-server inside my ES pod? Since ES might be very loaded, I prefer not to add a web-server to it.</p>
<p>The PV attached to ES pod also holds the logs. So I want to avoid any log-extraction-based solution to achieve getting this information over to pod #2.</p>

<p>You need get the PV details from kubernetes cluster API, where ever you are.</p>
<h3>Accessing the Kubernetes cluster API from within a Pod</h3>
<p>When accessing the API from within a Pod, locating and authenticating to the API server are slightly different to the external client case described above.</p>
<p>The easiest way to use the Kubernetes API from a Pod is to use one of the <a href="https://kubernetes.io/docs/reference/using-api/client-libraries/" rel="nofollow noreferrer">official client libraries</a>. These libraries can automatically discover the API server and authenticate.</p>
<h3>Using Official Client Libraries</h3>
<p>From within a Pod, the recommended ways to connect to the Kubernetes API are:</p>
<ul>
<li><p>For a Go client, use the official <a href="https://github.com/kubernetes/client-go/" rel="nofollow noreferrer">Go client library</a>. The rest.InClusterConfig() function handles API host discovery and authentication automatically. See <a href="https://git.k8s.io/client-go/examples/in-cluster-client-configuration/main.go" rel="nofollow noreferrer">an example here</a>.</p>
</li>
<li><p>For a Python client, use the official <a href="https://github.com/kubernetes-client/python/" rel="nofollow noreferrer">Python client library</a>. The config.load_incluster_config() function handles API host discovery and authentication automatically. See <a href="https://github.com/kubernetes-client/python/blob/master/examples/in_cluster_config.py" rel="nofollow noreferrer">an example here</a>.</p>
</li>
<li><p>There are a number of other libraries available, please refer to the <a href="https://kubernetes.io/docs/reference/using-api/client-libraries/" rel="nofollow noreferrer">Client Libraries</a> page.</p>
</li>
</ul>
<p>In each case, the service account credentials of the Pod are used to communicate securely with the API server.</p>
<h3>Reference</h3>
<p><a href="https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/#accessing-the-api-from-within-a-pod" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/#accessing-the-api-from-within-a-pod</a></p>
