New to Searchlight? Please start here.
Check command component-status
is used to check status of Kubernetes components. Returns OK if components are Healthy
, otherwise, returns Critical.
component-status
has the following variables:
selector
- Label selector for components whose existence are checked.componentName
- Name of Kubernetes component whose existence is checked.Execution of this command can result in following states:
At first, you need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. If you do not already have a cluster, you can create one by using Minikube.
Now, install Searchlight operator in your cluster following the steps here.
To keep things isolated, this tutorial uses a separate namespace called demo
throughout this tutorial. Run the following command to prepare your cluster for this tutorial:
$ kubectl create namespace demo
namespace "demo" created
$ kubectl get namespaces
NAME STATUS AGE
default Active 6h
kube-public Active 6h
kube-system Active 6h
demo Active 4m
In this tutorial, we are going to create a ClusterAlert to check status of all components.
$ cat ./docs/examples/cluster-alerts/component-status/demo-0.yaml
apiVersion: monitoring.appscode.com/v1alpha1
kind: ClusterAlert
metadata:
name: component-status-demo-0
namespace: demo
spec:
check: component-status
checkInterval: 30s
alertInterval: 2m
notifierSecretName: notifier-config
receivers:
- notifier: Mailgun
state: Critical
to: ["ops@example.com"]
$ kubectl apply -f ./docs/examples/cluster-alerts/component-status/demo-0.yaml
clusteralert "component-status-demo-0" created
$ kubectl describe clusteralert -n demo component-status-demo-0
Name: component-status-demo-0
Namespace: demo
Labels: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
6s 6s 1 Searchlight operator Normal SuccessfulSync Applied ClusterAlert: "component-status-demo-0"
Voila! component-status
command has been synced to Icinga2. Please visit here to learn how to configure notifier secret. Now, open IcingaWeb2 in your browser. You should see a Icinga host demo@cluster
and Icinga service component-status-demo-0
.
In this tutorial, a ClusterAlert will be used check status of a component by name by setting spec.componentName
field.
$ cat ./docs/examples/cluster-alerts/component-status/demo-1.yaml
apiVersion: monitoring.appscode.com/v1alpha1
kind: ClusterAlert
metadata:
name: component-status-demo-1
namespace: demo
spec:
check: component-status
vars:
componentName: etcd-0
checkInterval: 30s
alertInterval: 2m
notifierSecretName: notifier-config
receivers:
- notifier: Mailgun
state: Critical
to: ["ops@example.com"]
$ kubectl apply -f ./docs/examples/cluster-alerts/component-status/demo-1.yaml
clusteralert "component-status-demo-1" created
$ kubectl describe clusteralert -n demo component-status-demo-1
Name: component-status-demo-1
Namespace: demo
Labels: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
22s 22s 1 Searchlight operator Normal SuccessfulSync Applied ClusterAlert: "component-status-demo-1"
To pause alert, edit ClusterAlert component-status-demo-1
to set spec.paused
to be true
$ kubectl edit clusteralert component-status-demo-1 -n demo
spec:
pause: true
Searchlight operator will delete Icinga Services for this alert. To resume, edit and set spec.paused
to be false
To cleanup the Kubernetes resources created by this tutorial, run:
$ kubectl delete ns demo
If you would like to uninstall Searchlight operator, please follow the steps here.