Portainer icon

Portainer

Interact with Portainer via API

Actions190

Kubernetes → Delete Cron Jobs

AI-generated

Overview

This node operation allows users to delete Kubernetes Cron Jobs in bulk. It accepts a payload mapping namespaces to arrays of Cron Job names, then deletes the specified Cron Jobs within those namespaces. This is useful for automating cleanup or management of scheduled jobs in Kubernetes clusters, especially when managing multiple namespaces and many Cron Jobs at once.

Practical examples include:

  • Removing outdated or deprecated Cron Jobs across several namespaces.
  • Automating cleanup tasks after deployments or testing cycles.
  • Managing scheduled jobs programmatically without manual kubectl commands.

Properties

Name Meaning
Id Environment identifier (a required numeric ID) that likely specifies which Kubernetes environment or cluster to target.
Payload A JSON string representing a map where each key is a Kubernetes namespace and the value is an array of Cron Job names to delete in that namespace.

Example of Payload value:

{
  "default": ["cronjob1", "cronjob2"],
  "kube-system": ["system-cronjob"]
}

Output

The node outputs JSON data reflecting the result of the deletion requests. The exact structure depends on the API response but typically includes status information about each deletion attempt per Cron Job and namespace.

If binary data were involved (e.g., logs or files), it would be summarized here, but this node focuses on JSON responses related to resource deletion.

Dependencies

  • Requires access to a Kubernetes environment identified by the provided environment ID.
  • Needs appropriate API credentials or authentication tokens configured in n8n to communicate with the Kubernetes API.
  • The node uses HTTP requests to interact with the Kubernetes API endpoints for deleting Cron Jobs.

Troubleshooting

  • Invalid Environment ID: If the environment ID does not correspond to a valid Kubernetes cluster configuration, the node will fail to connect. Verify the environment ID and its configuration.
  • Malformed Payload: The payload must be a valid JSON string mapping namespaces to arrays of Cron Job names. Invalid JSON or incorrect structure will cause errors.
  • Permission Issues: Insufficient permissions to delete Cron Jobs in the specified namespaces will result in authorization errors. Ensure the API token or credentials have proper RBAC rights.
  • Nonexistent Cron Jobs: Attempting to delete Cron Jobs that do not exist may return errors or warnings. Confirm the Cron Job names are correct.
  • API Rate Limits or Network Errors: Temporary failures communicating with the Kubernetes API can occur; retry logic or error handling may be necessary.

Links and References

Discussion