Skip to main content

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
FieldDescriptionSchemeRequired
kindSpecifies the kind of Kubernetes object for interactionstringYes
resourceQueries resources related to specified Kubernetes objectResourceSelector
namespaceSelectorSpecifies namespace for Kubernetes objectResourceSelector
ignoreIgnore the specified resources from the fetched resources. Can be a glob pattern.[]string
readyCheck if resources are healthy using is-healthy if not fails the checkbool
nameName of the check, must be unique within the canarystringYes
descriptionDescription for the checkstring
iconIcon for overwriting default icon on the dashboardstring
labelsLabels for checkmap[string]string
testEvaluate whether a check is healthyExpression
displayExpression to change the formatting of the displayExpression
transformTransform data from a check into multiple individual checksExpression
metricsMetrics 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

FieldDescriptionSchemeRequired
nameName of Kubernetes resourcestring
labelSelectorSelect Kubernetes resource based on label. e.g. app, canary.string
fieldSelectorSelect Kubernetes resource based on the value of specified resource fieldstring