Kubectl using command to get cluster status

2/26/2019

I need to create a shell-script which examine the cluster Status.**

I saw that the kubectl describe-nodes provides lots of data I can output it to json and then parse it but maybe it’s just overkill. Is there a simple way to with kubectl command to get the status of the cluster ? just if its up / down

-- Jenny M
google-cloud-platform
kubectl
kubernetes

4 Answers

2/26/2019

The least expensive way to check if you can reach the API server is kubectl version. In addition kubectl cluster-info gives you some more info.

-- Michael Hausenblas
Source: StackOverflow

2/26/2019

In addition to Michael's answer, that would only tell you about the API server or master and internal services like KubeDns etc, but not the nodes.

It depends on your need and definition of "status" here. You could run kubectl cluster-info followed by kubectl get nodes and check the STATUS column for all nodes using parsing tools like awk, jq or kubectl's own -o jsonpath option to verify that all nodes are ready.

-- Hazim
Source: StackOverflow

2/26/2019

The below command would display the health of scheduler, controller and etcd

kubectl get cs

Command below lists Kubernetes core components like, etcd, controller, scheduler, kube-proxy, core-dns, network plugin. All those pods should be running to be sure that Kubernetes is healthy.

kubectl get pod -n kube-system

Finally deploy one front-end and back-end Pod and verify the inter-pod communication to ensure that cluster is up and working correctly.

-- P Ekambaram
Source: StackOverflow

6/25/2019

Below are the commands to get cluster status based on requirements:

  • To get information regarding where your Kubernetes master is running at, CoreDNS is running at, kubernetes-dasboard is running at, use kubectl cluster-info

  • To get detailed information to further debug and diagnose cluster problem, use kubectl cluster-info dump

  • To get only the health status for your node use, kubectl get componentstatus or kubectl get cs

*To show detailed information about a resource use kubectl describe node <node>

-- Rahul Arya
Source: StackOverflow