<p>Say you have a kubernetes installation, but you have no information about the time and the method the K8s cluster was installed.<br>
I am talking about the K8s infrastructure itself and not K8s applications running on the cluster.</p>
<p>How would you find that?</p>
<p>I am looking for something like this:</p>
<pre><code>kubectl/kubeadm(or some other command) cluster info
</code></pre>
<p>and for responses like these:<br>
(<em>method/date/nodes</em>)</p>
<ul>
<li><code>kubeadm-manually 2020-10-10T12:06:43 3nodes</code></li>
<li><code>RKE 2020-10-10T12:06:43 3nodes</code></li>
<li><code>EKS 2020-10-10T12:06:43 3nodes</code></li>
</ul>
<p>Currently what I am doing is looking for traces on the filesystem and on kubernetes resources (whether method specific pods,namespaces,labels..etc are exists)</p>

<h2>kubectl cluster-info</h2>
<p>There is a command <a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/#interacting-with-nodes-and-cluster" rel="nofollow noreferrer">kubectl cluster-info</a>, but it shows only endpoint information about the master and services in the cluster.</p>
<p>Example from docker desktop.</p>
<pre><code>kubectl cluster-info
Kubernetes master is running at https://kubernetes.docker.internal:6443
KubeDNS is running at https://kubernetes.docker.internal:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
</code></pre>
<p>Example from gke</p>
<pre><code>kubectl cluster-info
Kubernetes master is running at https://xx.xxx.xxx.xx
GLBCDefaultBackend is running at https://xx.xxx.xxx.xx/api/v1/namespaces/kube-system/services/default-http-backend:http/proxy
KubeDNS is running at https://xx.xxx.xxx.xx/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://xx.xxx.xxx.xx/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy
</code></pre>
<hr />
<h2>Number of nodes</h2>
<p>If you wan't to check how many nodes are in your cluster you can use <a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/#viewing-finding-resources" rel="nofollow noreferrer">kubectl get nodes</a>.</p>
<p>Example from docker on desktop.</p>
<pre><code>kubectl get nodes
NAME             STATUS   ROLES    AGE     VERSION
docker-desktop   Ready    master   5d22h   v1.19.3
</code></pre>
<p>Example from gke</p>
<pre><code>kubectl get nodes
NAME                                       STATUS   ROLES    AGE     VERSION
gke-cluster-4-default-pool-ae8cecd9-m6br   Ready    &lt;none&gt;   2d16h   v1.16.13-gke.401
gke-cluster-4-default-pool-ae8cecd9-n9nz   Ready    &lt;none&gt;   2d16h   v1.16.13-gke.401
gke-cluster-4-default-pool-ae8cecd9-tb9f   Ready    &lt;none&gt;   2d16h   v1.16.13-gke.401
</code></pre>
<p>If you wan't to get just the number of running nodes .</p>
<pre><code>kubectl get nodes --no-headers | grep -v Running | wc -l
</code></pre>
<hr />
<h2>Method</h2>
<p>You could try to do that with few commands from this <a href="https://stackoverflow.com/questions/38242062/how-to-get-kubernetes-cluster-name-from-k8s-api">stackoverflow</a> question.</p>
<p>For example:</p>
<ul>
<li><code>kubectl config current-context</code></li>
<li><code>kubectl config view -o jsonpath='{.clusters[].name}'</code></li>
<li><code>kubectl -n kube-system get configmap kubeadm-config -o yaml &lt;--- kubeadm only</code></li>
</ul>
<hr />
<h2>Date</h2>
<p>Couldn't find any informations about that, as a workaround you can try to check nodes/kube api-server creationTimestamp, but if there was any restart on the node/kube api-server pod then the data will get updated.</p>
<p>Example from docker desktop.</p>
<pre><code>kubectl get node docker-desktop -o jsonpath='{.metadata.creationTimestamp}'
2020-11-13T10:09:10Z

kubectl get pods -n kube-system kube-apiserver-docker-desktop -o jsonpath='{.metadata.creationTimestamp}' 
2020-11-13T10:10:12Z
</code></pre>
