<p>Does kubernetes provide an API in its client library to get the cluster-info dump?
I went through its API <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.12/#-strong-api-overview-strong-" rel="nofollow noreferrer">documentation</a> and could find any API which could actually do this.</p>
<p><strong>What i do now:</strong></p>
<pre><code>kubectl cluster-info dump --output-directory=&quot;dumpdir&quot;
</code></pre>
<p><strong>What i want:</strong></p>
<p>Using client-go/kubernetes API libraries, make an API call to get this dump from a golang application. Is it possible?</p>
<p><strong>What i know:</strong></p>
<p>There are individual API's for each resource which can provide all the information provided by the cluster-info dump, but i want to do it will a single API call.</p>
<p>For example, this Golang code will give me a list of nodes:</p>
<pre><code>coreClient := kubernetesapi.CoreV1()
nodeList, err := coreClient.Nodes().List(metav1.ListOptions{})
</code></pre>
<p>Is there an API which returns what <code>kubectl cluster-info dump</code> would give, so that I can get all the details programmatically?</p>

Bharath
<p>You can capture API calls by listing the output with verbose option in <code>kubectl cluster-info</code> command:</p>

<p><code>kubectl cluster-info dump -v 9</code></p>

<p>For example:</p>

<blockquote>
  <p>curl -k -v -XGET  -H "Accept: application/json, <em>/</em>" -H "User-Agent:
  kubectl/v1.12.1 (linux/amd64) kubernetes/4ed3216"
  '<a href="https://10.142.0.3:6443/api/v1/namespaces/kube-system/events" rel="nofollow noreferrer">https://10.142.0.3:6443/api/v1/namespaces/kube-system/events</a>'</p>
</blockquote>

<p>Get the token for authorization purpose in your cluster:</p>

<p><code>MY_TOKEN="$(kubectl get secret &lt;default-secret&gt; -o jsonpath='{$.data.token}' | base64 -d)"</code></p>

<p>Now you can make API call for the target resource:</p>

<pre><code>curl -k -v -H "Authorization : Bearer $MY_TOKEN" https://10.142.0.3:6443/api/v1/namespaces/kube-system/events
</code></pre>

<p>Keep in mind that you may require role binding in order to grant view permission for your service account:</p>

<pre><code>apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: default-view
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: view
subjects:
  - kind: ServiceAccount
    name: default
    namespace: default
</code></pre>
