agapoff / check_kubernetes

Nagios/Icinga/Zabbix style plugin for checking Kubernetes
64 stars 36 forks source link

How to use the script with kubectl config. #2

Closed aguzmans closed 4 years ago

aguzmans commented 4 years ago

I have a test cluster that I am trying to access using your script to see if it could work for me in some monitoring projects I will do with Zabbix. I am tryin to use the script from this server where I have kubectl: # kubectl --insecure-skip-tls-verify --kubeconfig=/var/lib/zabbix/zabbix-kubernetes/.kube/config get deployments -n kube-system NAME READY UP-TO-DATE AVAILABLE AGE coredns 2/2 2 2 37h

The --insecure-skip-tls-verify Flag is for the cluster to ignore the ssl verification. In my case I have to use it as the kubectl config that I have is NOT for the IP that I am testing from. I am not sure if this is related to the problem, but I need to also be able to pass this flag to the script. Anyways. I do not think the first problem I am getting is related to that.

This is why. I tried to use the script and can not get it to work check out the output:

# ./k8s.sh -m deployments -H https://MY_IP:6443 -K /var/lib/zabbix/zabbix-kubernetes/.kube/config -N kube-system -n core-dns Usage ./k8s.sh [-m <MODE>|-h] [-o <TIMEOUT>] [-H <APISERVER> [-T <TOKEN>|-t <TOKENFILE>]] [-K <KUBE_CONFIG>] [-N <NAMESPACE>] [-n <NAME>] [-w <WARN>] [-c <CRIT>]

Options are: -m MODE Which check to perform -H APISERVER API URL to query, kubectl is used if this option is not set (...) ` tls Check for tls secrets expiration dates``

What am I doing wrong. How should I go about this?

BornTKill commented 4 years ago

Dear,

When specifying -H, you must specify TOKEN.

aguzmans commented 4 years ago

Hi and thanks for the response @BornTKill ,

I ended up using a different monitoring script for Zabbix. but I am interested about checking if yours can do more than the other. So I will test later and provide feedback.

Regards Abel

BornTKill commented 4 years ago

Dear @aguzmans,

I’m using this one with icinga2. Which one did you try ? On my side I’ve test another (kube-icinga) but I don’t like the way it calls Icinga API (push instead of pull as this one does). Let you know if my choice was the best in the future.

Best regards.

aguzmans commented 4 years ago

I use Zabbix 4.4 @BornTKill, The scripts I am using now are these. I am not 100% happy with them, but they do detect many problems and give some general information. Another thing is that those are perl scripts and have software requirements. I'm still exploring the subject. These scripts connect to K8s API and then push to zabbix using zabbix_sender. For now I am running them from the zabbix server host, but they should be able to run on a zabbix proxy as well or other hosts as long as the host is able to connect to a zabbix end point. The scripts will not be usefull for icinga2 directly.