1

Say you have a kubernetes installation, but you have no information about the time and the method the K8s cluster was installed.
I am talking about the K8s infrastructure itself and not K8s applications running on the cluster.

How would you find that?

I am looking for something like this:

kubectl/kubeadm(or some other command) cluster info

and for responses like these:
(method/date/nodes)

  • kubeadm-manually 2020-10-10T12:06:43 3nodes
  • RKE 2020-10-10T12:06:43 3nodes
  • EKS 2020-10-10T12:06:43 3nodes

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)

beatrice
  • 3,684
  • 5
  • 22
  • 49

1 Answers1

2

kubectl cluster-info

There is a command kubectl cluster-info, but it shows only endpoint information about the master and services in the cluster.

Example from docker desktop.

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

Example from gke

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

Number of nodes

If you wan't to check how many nodes are in your cluster you can use kubectl get nodes.

Example from docker on desktop.

kubectl get nodes
NAME             STATUS   ROLES    AGE     VERSION
docker-desktop   Ready    master   5d22h   v1.19.3

Example from gke

kubectl get nodes
NAME                                       STATUS   ROLES    AGE     VERSION
gke-cluster-4-default-pool-ae8cecd9-m6br   Ready    <none>   2d16h   v1.16.13-gke.401
gke-cluster-4-default-pool-ae8cecd9-n9nz   Ready    <none>   2d16h   v1.16.13-gke.401
gke-cluster-4-default-pool-ae8cecd9-tb9f   Ready    <none>   2d16h   v1.16.13-gke.401

If you wan't to get just the number of running nodes .

kubectl get nodes --no-headers | grep -v Running | wc -l

Method

You could try to do that with few commands from this stackoverflow question.

For example:

  • kubectl config current-context
  • kubectl config view -o jsonpath='{.clusters[].name}'
  • kubectl -n kube-system get configmap kubeadm-config -o yaml <--- kubeadm only

Date

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.

Example from docker desktop.

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
Jakub
  • 8,189
  • 1
  • 17
  • 31