Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubectl using command to get cluster status

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

like image 944
Jenny M Avatar asked Feb 26 '19 09:02

Jenny M


People also ask

How do I check my cluster status on kubectl?

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.

How do I check my Kubernetes status?

If the output from a specific pod is desired, run the command kubectl describe pod pod_name --namespace kube-system . The Status field should be "Running" - any other status will indicate issues with the environment. In the Conditions section, the Ready field should indicate "True".

How do you view the cluster events using the kubectl command?

You can use kubectl get events --output json to check the data structure. $ kubectl get events --output json { "apiVersion": "v1", "items": [ { "apiVersion": "v1", "count": 259, "eventTime": null, "firstTimestamp": "2020-04-15T12:00:46Z", "involvedObject": { <------ **this** "apiVersion": "v1", "fieldPath": "spec.


2 Answers

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.

like image 174
Michael Hausenblas Avatar answered Nov 02 '22 00:11

Michael Hausenblas


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>

like image 44
Rahul Arya Avatar answered Nov 02 '22 01:11

Rahul Arya