Actions90
- Namespaces Actions
- Pods Actions
- Services Actions
- Deployments Actions
- ReplicaSets Actions
- StatefulSets Actions
- DaemonSets Actions
- Jobs Actions
- CronJobs Actions
CronJobs → Exec
AI-generatedOverview
This node enables interaction with Kubernetes resources, specifically supporting operations on various resource types including CronJobs. The exec operation allows executing commands inside a container of a Kubernetes pod associated with the specified resource.
For the CronJobs resource with the exec operation, the node executes a command inside a pod related to the CronJob in the specified namespace. This is useful for debugging or managing running jobs by running arbitrary commands within their containers.
Common scenarios:
- Running diagnostic commands inside pods spawned by CronJobs.
- Executing maintenance or inspection commands without needing direct kubectl access.
- Automating operational tasks that require command execution inside job pods.
Example:
You want to run a shell command inside a pod created by a CronJob named "backup-job" in the "default" namespace to check logs or environment variables.
Properties
| Name | Meaning |
|---|---|
| Image | The container image name used when running or restarting pods; relevant for exec if needed. |
| Namespace | Kubernetes namespace where the CronJob and its pods reside (default is "default"). |
| Resource Name | The specific name of the CronJob resource to target for the exec operation. |
Note: Although the bundled properties include Image, it is not directly used in the exec operation logic shown, but is required for other operations like run.
Output
The output is a JSON array containing the result of the executed command inside the pod. Specifically, the stdout field contains the standard output from the command run inside the pod's container.
Example output structure:
[
{
"stdout": "<command output as string>"
}
]
No binary data output is indicated for this operation.
Dependencies
- Requires valid Kubernetes API credentials configured in n8n to authenticate and interact with the cluster.
- Depends on an internal Kubernetes client utility (
K8SClient) to perform API calls and execute commands inside pods. - The node expects the command input as a JSON array representing the command and its arguments.
Troubleshooting
Error: "No credentials got returned!"
This indicates missing or invalid Kubernetes API credentials. Ensure credentials are properly set up and linked to the node.Error: "Command must be an array!"
Thecommandproperty must be a JSON array (e.g.,["ls", "-l"]). Providing a string or other type will cause this error.Execution failures inside pods
If the command fails inside the pod, verify the pod is running and accessible, and that the command is valid in the container environment.Resource or namespace not found
Confirm the specifiedresourceNameandnamespaceexist in the Kubernetes cluster.
Links and References
- Kubernetes Exec API - Official docs on executing commands inside containers.
- Kubernetes Field Selectors
- Kubernetes Label Selectors