Kubernetes
The Kubernetes check performs requests on Kubernetes resources such as Pods to get the desired information.
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: kube-system-checks
spec:
interval: 30
kubernetes:
# failing checks will be inserted into kube-system, irrespective of which
# namespace this canary is created in
- namespace: kube-system
name: kube-system
kind: Pod
ready: true
resource:
labelSelector: k8s-app=kube-dns
namespaceSelector:
name: kube-system
Field | Description | Scheme | Required |
---|---|---|---|
kind | Specifies the kind of Kubernetes object for interaction | string | Yes |
resource | Queries resources related to specified Kubernetes object | ResourceSelector | |
namespaceSelector | Specifies namespace for Kubernetes object | ResourceSelector | |
ignore | Ignore the specified resources from the fetched resources. Can be a glob pattern. | []string | |
ready | Check if resources are healthy using is-healthy if not fails the check | bool | |
name | Name of the check, must be unique within the canary | string | Yes |
description | Description for the check | string | |
icon | Icon for overwriting default icon on the dashboard | string | |
labels | Labels for check | map[string]string | |
test | Evaluate whether a check is healthy | Expression | |
display | Expression to change the formatting of the display | Expression | |
transform | Transform data from a check into multiple individual checks | Expression | |
metrics | Metrics to export from | []Metrics |
Ready
Using ready: true
is functionally equivalent to:
apiVersion: canaries.flanksource.com/v1
kind: Canary
metadata:
name: kube-system-checks
spec:
interval: 30
kubernetes:
- namespace: kube-system
name: kube-system
kind: Pod
resource:
labelSelector: k8s-app=kube-dns
namespaceSelector:
name: kube-system
display:
expr: |
dyn(results).
map(i, i.Object).
filter(i, !k8s.isHealthy(i)).
map(i, "%s/%s -> %s".format([i.metadata.namespace, i.metadata.name, k8s.getHealth(i).message])).join('\n')
test:
expr: dyn(results).all(x, k8s.isHealthy(x))
See the CEL Kubernetes docs for more details on the k8s.isHealthy
and other functions available
ResourceSelector
Field | Description | Scheme | Required |
---|---|---|---|
name | Name of Kubernetes resource | string | |
labelSelector | Select Kubernetes resource based on label. e.g. app, canary. | string | |
fieldSelector | Select Kubernetes resource based on the value of specified resource field | string |