Skip to content

Overview and install

The agent runs in your cluster, discovers your CronJobs and reports when their Jobs start, succeed or fail, and why. You do not add ping calls to your CronJobs.

The agent is a plan feature (Free: none, Pro: 1 cluster, Enterprise: 10 clusters), see Plans and limits.

Kubernetes CronJobs fail in ways a ping cannot see: the pod is OOMKilled, the image cannot be pulled, the CronJob is suspended or deleted. The agent watches the cluster from inside and tells CronBeat, so you get the failure reason without editing any CronJob.

On Pro or Enterprise, when you run CronJobs and want them discovered and monitored automatically. For one or two jobs, or on Free, the manual ping method works too.

  1. On start and then every 5 minutes it sends the full list of CronJobs (namespace, name, uid, schedule, time zone, suspend flag) to CronBeat.
  2. For every CronJob CronBeat creates a monitor (one per <namespace>/<name>) with the cron schedule and a default grace period of 600 seconds. Created monitors count toward your monitor limit. When the limit is reached, no new monitors are created and the sync response carries a warning.
  3. A CronJob with suspend: true pauses its monitor, un-suspending resumes it. A CronJob that disappears from the cluster is not deleted in CronBeat, its monitor is paused.
  4. For every Job that belongs to a CronJob (ownerReferences of kind CronJob; other Jobs are ignored) it sends job_started when the Job is created, job_succeeded when it completes (with the duration) and job_failed when it fails (with a reason and a message). CronBeat turns these into start, success and fail pings.
  5. Every 60 seconds it sends a heartbeat.
  6. Optional annotations on a CronJob set its grace period and maximum runtime or leave it out, see Configure a CronJob with annotations.

The complete list of permissions and data is on Agent permissions and data.

  • Read-only RBAC. The chart creates a ClusterRole with only list and watch on cronjobs and jobs (batch) and on pods (core). No access to Secrets or pod logs, no write permissions.
  • Outbound only. The agent makes HTTPS requests to the CronBeat API. It listens on one port (healthPort, default 8081) for the liveness and readiness probes only and creates no Service.
  • The pod runs as non-root with a read-only root filesystem, without privilege escalation and with all capabilities dropped.
  • The API key is read from a Kubernetes Secret and only sent in the Authorization header. CronBeat stores a hash of it.
  • What leaves the cluster: CronJob metadata (namespace, name, uid, schedule, time zone, suspend) and Job events (job uid, timestamps, duration, failure reason and a short message such as container backup terminated: OOMKilled (exit code 137, memory limit 256Mi)). Of the pod spec only the memory limit of each container is read. Environment variables, images, commands and container logs are never read or sent. The message Kubernetes gives for a waiting container (for example secret "db-credentials" not found) is included in the failure message: it can contain the name of a Secret or an image, never a value.
  • With watchNamespaces set the agent only watches those namespaces and the chart creates a Role per namespace instead of a ClusterRole, so it has no cluster-wide access.
  • Kubernetes 1.27 or newer (the chart requires it, CronJob spec.timeZone is used).
  • Outbound HTTPS from the cluster to api.cronbeat.dev.
  • An agent API key. Create it in the app under Agents: enter the cluster name and copy the key (it starts with cb_agent_ and is shown once).

Put these on the CronJob (metadata.annotations) to keep the monitor settings next to your manifest:

Annotation Value Effect
cronbeat.dev/grace 90 (seconds), 10m, 1h30m or 2d; 1 second to 7 days Grace period of the monitor. Default: 10 minutes
cronbeat.dev/max-runtime Same formats; 1 second to 24 hours A run longer than this is reported as too long
cronbeat.dev/ignore true CronJob is not monitored. An existing monitor is paused
apiVersion: batch/v1
kind: CronJob
metadata:
name: nightly-backup
annotations:
cronbeat.dev/grace: "15m"
cronbeat.dev/max-runtime: "2h"
  • An invalid value is ignored and shown in the agent log, nothing else is affected.
  • While an annotation is present the agent sets the value on every sync, so a change you make in the app is replaced. Removing an annotation leaves the monitor as it is; change it in the app if you want another value.
  • Changes are picked up within seconds.

The Agents page shows the version each agent reports. When a newer version is published, the agent gets an Update available badge and the page shows the exact command for each agent that is behind. For an agent installed with the command from the app (release cronbeat-agent-<cluster>, namespace cronbeat-agent) it looks like this:

Terminal window
helm upgrade cronbeat-agent-prod-eu cronbeat-agent --repo https://repo.repsy.io/nuricanozturk/cronbeat-agent --namespace cronbeat-agent --reset-then-reuse-values

If you installed the agent another way, find the release name and namespace first and put them in the same command:

Terminal window
helm list --all-namespaces | grep cronbeat-agent

RELEASE and NAMESPACE in a template command are placeholders: use the real names from that list. A name such as RELEASE is refused by Helm (release name is invalid). --reset-then-reuse-values keeps what you set at install time (API key, cluster name, watched namespaces) and takes new defaults from the chart. The pod restarts with the new image; events of a Job that finishes during the restart are sent when the agent is back. The version on the page updates after the next heartbeat. Do this once per agent.

To split a cluster (for example one agent for the namespace gitnode), install one agent per part. Each agent needs its own cluster name and its own Helm release name. The command in the app names the release after the cluster (cronbeat-agent-gitnode), so the commands do not collide. Do not let two agents watch the same namespace: you would get every CronJob twice and every alert twice.

Monitors the agent creates sit in the same Monitors list as your ping and HTTP monitors, with the label Kubernetes · cluster-name under the name. Once you have more than one kind of monitor, tabs appear above the list: All, Ping, HTTP checks and Kubernetes, each with its count. On the Kubernetes tab, with two or more clusters, you can narrow the list to one cluster. The tab and cluster are kept in the address, so you can bookmark a view.

Terminal window
helm install cronbeat-agent-prod-eu cronbeat-agent --repo https://repo.repsy.io/nuricanozturk/cronbeat-agent \
--namespace cronbeat-agent --create-namespace \
--set apiKey=cb_agent_... \
--set clusterName=prod-eu

To keep the key in a Secret that you manage yourself:

Terminal window
kubectl create namespace cronbeat-agent
kubectl -n cronbeat-agent create secret generic cronbeat-agent-key --from-literal=api-key=cb_agent_...
helm install cronbeat-agent-prod-eu cronbeat-agent --repo https://repo.repsy.io/nuricanozturk/cronbeat-agent -n cronbeat-agent \
--set existingSecret=cronbeat-agent-key --set clusterName=prod-eu

By default the agent watches every namespace. In the app, type the namespace names (separated by commas) into the Namespaces (optional) field above the install command and the command is rewritten for you. To do it by hand, list the namespaces:

Terminal window
helm install cronbeat-agent-prod-eu cronbeat-agent --repo https://repo.repsy.io/nuricanozturk/cronbeat-agent -n cronbeat-agent --create-namespace \
--set apiKey=cb_agent_... --set clusterName=prod-eu \
--set 'watchNamespaces={team-a,team-b}'

The chart then creates a Role and RoleBinding in each listed namespace instead of a cluster wide ClusterRole, so the agent has no access to anything else.

Two things to know:

  • The CronJob list the agent sends is treated as complete for that cluster name. CronJobs that are no longer in it get their monitors paused. If you narrow watchNamespaces later, the monitors of the namespaces you dropped are paused.
  • Do not run two agents with the same cluster name to split namespaces between them: each would pause the other’s monitors. Give every agent its own cluster name (for example prod-eu-team-a).

Check that it runs:

Terminal window
kubectl -n cronbeat-agent rollout status deploy/cronbeat-agent-prod-eu
kubectl -n cronbeat-agent logs deploy/cronbeat-agent-prod-eu

The Deployment name is derived from the release name; use kubectl -n cronbeat-agent get deploy if yours differs.

Key Default Description
clusterName (required) Cluster name. The server uses the cluster name registered with the key.
apiKey "" Agent API key, stored in a Secret created by the chart.
existingSecret "" Name of your own Secret that holds the key (instead of apiKey).
existingSecretKey api-key Key inside existingSecret.
apiUrl https://api.cronbeat.dev CronBeat API base URL.
watchNamespaces [] Namespaces to watch, empty means all.
healthPort 8081 Port of the /healthz and /readyz probes.
goMemLimit 200MiB Go soft memory limit, keep about 20% below the memory limit.
logLevel info debug, info, warn or error.
image.repository repo.repsy.io/nuricanozturk/cronbeat-agent-bin/agent Override it to use your own mirror.
image.tag chart appVersion Image tag.
image.pullPolicy IfNotPresent
imagePullSecrets []
resources 20m / 64Mi requests, 200m / 256Mi limits Raise the memory limit for clusters with many thousands of pods.
nodeSelector, tolerations, affinity empty Scheduling.
podAnnotations, podLabels empty
serviceAccount.create, .name, .annotations true, release name, empty
nameOverride, fullnameOverride empty

clusterName is required, and one of apiKey or existingSecret must be set.

  • Events are queued in memory and are not persisted. An event still queued when the pod dies is lost.
  • After a restart the agent re-sends events of Jobs that still exist, but skips events older than one hour so cluster history is not replayed. CronBeat de-duplicates by job uid and event type.
  • Failed deliveries are retried with backoff on network errors, 5xx and 429. Other 4xx responses are not retried.
  • One replica, no leader election. Running two would not corrupt data but would double the traffic.
  • If a Job’s pod was created and removed while the agent was not running, the container level reason cannot be recovered. Only the reason on the Job itself is available.
Situation Result
You create a new CronJob Within 5 minutes (next sync) a monitor with its cron schedule appears.
A Job fails with OOMKilled The monitor goes down at once with the reason and message in the alert.
You suspend a CronJob Its monitor is paused. Un-suspending resumes it.
You delete a CronJob Its monitor is not deleted, it is paused.
The agent is silent for 3 minutes One agent_lost incident opens, the monitors of that cluster are not judged meanwhile, see Failure reasons and agent loss.
The plan allows fewer agents Only the oldest agents that fit the new limit keep working, the others get 401 (Free: none). Nothing is deleted.
You revoke an agent key The agent gets 401. A revoked agent can be deleted permanently in the app.
The plan monitor limit is reached No new monitors are created and the sync reports a warning.