Kubernetes icon

Kubernetes

Interact with Kubernetes

Overview

This node enables interaction with Kubernetes clusters by performing various operations on Kubernetes resources. Specifically, for the CronJobs resource with the List operation, it retrieves a list of CronJob resources from a specified namespace in the Kubernetes cluster. Users can filter the results using field selectors or label selectors to narrow down the returned CronJobs.

Common scenarios where this node is beneficial include:

  • Automating monitoring or auditing of scheduled jobs (CronJobs) running in Kubernetes.
  • Integrating Kubernetes CronJob data into workflows for reporting or triggering downstream processes.
  • Filtering and retrieving specific CronJobs based on labels or fields for management or analysis.

For example, you might use this node to list all CronJobs in the "default" namespace that have a particular label indicating their environment (e.g., env=production), then trigger alerts or further automation based on their status.

Properties

Name Meaning
Namespace The Kubernetes namespace from which to list the CronJobs. Defaults to "default".
Resource Name (Optional) Specific name of a CronJob resource to retrieve. If provided, filters the list to this resource only.
Field Selector A Kubernetes field selector string to filter the CronJobs by specific fields (e.g., metadata.name=my-cronjob).
Label Selector A Kubernetes label selector string to filter the CronJobs by labels (e.g., app=my-app).

Output

The output is a JSON array containing the retrieved CronJob resources matching the specified criteria. Each item in the array represents a CronJob object as returned by the Kubernetes API, including metadata, spec, and status fields.

Example structure of one item in the output JSON array:

{
  "apiVersion": "batch/v1beta1",
  "kind": "CronJob",
  "metadata": {
    "name": "example-cronjob",
    "namespace": "default",
    "labels": { ... },
    ...
  },
  "spec": {
    "schedule": "*/5 * * * *",
    "jobTemplate": { ... },
    ...
  },
  "status": {
    "active": [ ... ],
    "lastScheduleTime": "2024-06-01T12:00:00Z",
    ...
  }
}

No binary data output is produced by this operation.

Dependencies

  • Requires valid Kubernetes API credentials configured in n8n to authenticate and communicate with the Kubernetes cluster.
  • The node depends on an internal Kubernetes client utility to perform API calls.
  • Proper network access to the Kubernetes API server is necessary.

Troubleshooting

  • No credentials got returned!
    This error indicates missing or misconfigured Kubernetes API credentials. Ensure that the node has been provided with valid credentials that allow access to the target cluster.

  • Command must be an array!
    Although not relevant for the List operation, this error may appear if other operations are used incorrectly. For List, ensure that field and label selectors are valid strings.

  • Empty result set
    If no CronJobs are returned, verify that the namespace is correct and that any field or label selectors match existing resources.

  • API access errors (e.g., 403 Forbidden, 404 Not Found)
    Check that the credentials have sufficient permissions and that the resource names and namespaces exist.

Links and References

Discussion