Skip to content

small utility to check basic health of k8s cluster

Notifications You must be signed in to change notification settings

mbrookhuis/k8s-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tool to perform a simple healthcheck on a kubernetes cluster

Overview

This tool will run a simple healthcheck on a kubernetes cluster. It will perform the following actions:

  • node check: This will check all nodes, and display the status and the k3s version. If the status of the nodes is not "Ready" (this should be only reported), the cluster will be reported as having problems
  • deployment check: This check will list all deployments, and display the number of expected replicas and the used replica. If there are unused replicas this will be displayed. The cluster will be reported as having problems.
  • pvc check: This check will list of all pvc's, and display the status and the robustness. If the robustness is not "Healthy", the cluster will be reported as having problems.

If there is a problem registered in the checks, there will be a warning that the cluster is not healthy and the program will exit with 1.

The script has 1 mandatory parameter and that is the kubeconf of the cluster or of a node off the cluster.

The code is writen for Python 3.11, but will also work on 3.6 (the default with SLES15.x). There is a venv present that will contain all needed packages. Also, the script can be run on the cluster itself or any other linux server.

Table of contents

Installation

To install this project, perform the following steps:

  • Create the directory /opt/k8s-check
mkdir /opt/k8s-check
  • Copy all the file to this directory and make the following changes:
chmod +x k8s-check.py

note:

If you want to run this program in you on python environment or the default of the server, please perform the following actions:

  • install the needed modules:
pip install tabulate kubernetes
  • change the first line of k8s-check.py to:
#!/usr/bin/env python3

Usage

As mentioned above, for the executing of the script the kubeconfig is needed. If this happens on the node, please use the local kubeconfig (e.g. for k3s this will be: /etc/rancher/k3s/k3s.yaml). If the script is run on a different server, copy the kubeconfig to this server. Executing the following will do the magic:

/opt/k8s-check --kubeconfig <kubeconfig>

About

small utility to check basic health of k8s cluster

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published