service-endpoints-check CLI usage
The tool basically expects 3 input information to function:
These values can be provided in 3 different ways:
As flags to the command
For eg, the following command can be used to check if the service nginx
has
atleast 2 endpoints at all times in default namespace.
$ service-endpoints-check --service nginx --min-ep 2
# output
INFO[0000] Service nginx-deploy of namespace default has requested number of endpoints(2)
min-ep
(minimum endpoints) and namespace
flags are optional and will get
default values 1
and default
respectively.
As environment variables
If no flags are provided, the tool looks for environment variables for getting
the information. To avoid possible confusion, the environment variables has the
prefix SEC
. The usage can be as follows:
$ export SEC_SERVICE=nginx # ENV var for service
$ export SEC_MIN_EP=4 # ENV var for min-ep, notice that `-` becomes `_`
$ service-endpoints-check --KUBECONFIG ~/.kubeconfig
#output
FATA[0000] Endpoints of service nginx (namespace: default) are fewer that
expected: required 4 got 2
exit status 1
The default values for namespace and min-ep remains the same.
As configuration file
If the tool couldn't find the values in the above two cases, it looks for a
configuration file with the data. By default, it looks for the file
$HOME/.service-endpoints-check.yaml
if a flag --config
with the right file
is not provided.
An example usage is:
$ cat /home/username/.config
service: nginx
namespace: dev
min-ep: 3
$ service-endpoints-check --config /home/username/.config
FATA[0000] services "nginx" not found
exit status 1
Monitoring a remote cluster
By default, the tool expects the Kuberentes cluster is present in the local and
hence look for a kubeconfig ~/.kube/config
. To override this and connect to a
remote cluster, one could use the flag --KUBECONFIG
(or env var
SEC_KUBECONFIG
or provide in the config file being used under a key KUBECONFIG
).
An example usage is:
$ export KUBECONFIG=/home/username/kubebin/kubeconfig
$ service-endpoints-check --service nginx
INFO[0000] Service nginx of namespace default has requested number of endpoints(1)