CEL cheatsheet

Common Expression Language (CEL) expressions for checking the health of custom resources.

About

The Kustomization API supports defining custom logic for performing health checks on custom resources through the field .spec.healthCheckExprs. This field accepts a set of Common Expression Language (CEL) expressions.

Here you can find a set of community-maintained CEL expressions for popular custom resources.

Contributing

For contributing to this library, open a pull request making changes to this file:

https://github.com/fluxcd/website/blob/main/content/en/flux/cheatsheets/cel-healthchecks.md

Please make sure to test your expressions and post evidence of their correctness in the pull request, i.e. configure a Kustomization with the expressions, verify that they work as expected and post logs or screenshots in the pull request.

The CEL Playground is a useful resource for testing your expressions. The input passed to each expression is the custom resource object itself.

Library

The items in this library are sorted in alphabetical order.

CephCluster

The CephCluster resource in this example is created by the rook-ceph-cluster Flux HelmRelease.

healthChecks:
  - apiVersion: helm.toolkit.fluxcd.io/v2
    kind: HelmRelease
    name: rook-ceph-cluster
    namespace: rook-ceph
  - apiVersion: ceph.rook.io/v1
    kind: CephCluster
    name: rook-ceph
    namespace: rook-ceph
healthCheckExprs:
  - apiVersion: ceph.rook.io/v1
    kind: CephCluster
    failed: status.ceph.health == 'HEALTH_ERR'
    current: status.ceph.health == 'HEALTH_OK'

Cluster

healthCheckExprs:
  - apiVersion: cluster.x-k8s.io/v1beta1
    kind: Cluster
    failed: status.conditions.filter(e, e.type == 'Ready').all(e, e.status == 'False')
    current: status.conditions.filter(e, e.type == 'Ready').all(e, e.status == 'True')

ClusterIssuer

healthCheckExprs:
  - apiVersion: cert-manager.io/v1
    kind: ClusterIssuer
    failed: status.conditions.filter(e, e.type == 'Ready').all(e, e.status == 'False')
    current: status.conditions.filter(e, e.type == 'Ready').all(e, e.status == 'True')

ClusterSecretStore

healthCheckExprs:
  - apiVersion: external-secrets.io/v1beta1
    kind: ClusterSecretStore
    failed: status.conditions.filter(e, e.type == 'Ready').all(e, e.status == 'False')
    current: status.conditions.filter(e, e.type == 'Ready').all(e, e.status == 'True')

ScaledObject

healthCheckExprs:
  - apiVersion: keda.sh/v1alpha1
    kind: ScaledObject
    failed: status.conditions.filter(e, e.type == 'Ready').all(e, e.status == 'False')
    current: status.conditions.filter(e, e.type == 'Ready').all(e, e.status == 'True')

SealedSecret

healthCheckExprs:
  - apiVersion: bitnami.com/v1alpha1
    kind: SealedSecret
    failed: status.conditions.filter(e, e.type == 'Synced').all(e, e.status == 'False')
    current: status.conditions.filter(e, e.type == 'Synced').all(e, e.status == 'True')