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
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.
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".
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With